开发者

What should we prefer to use Stored Proc or Prepared statements

I have recently started working on Databases. I know the basic difference between Stored Procedures and Prepared Statements. But can just brief me an idea that when we have to use which one. My trainer told me both are used when you have to execute a command often but then which one we should go for. I have heard that Stored procedures are always preferred. I know Stored procedures are pre-compiled and written in database. I can accept if someone says actually there is no similarity between the two so no question of differences and usage preference, but still I putted this question as I am un开发者_运维百科aware of these things. I am using SQL Server 2008 Express with C#. Can some one help me out please.


Use both? Stored procedures for writes, prepared statements for reads?

Why?

  • Command-query separation
  • RDBMS deals with transactions, data integrity etc (eg less round trips to check a condition)
  • Clients are not constrained to stored procedures for reads (but would still use a view or UDF: never raw tables)

Oherwise, there is no correct answer because it will be different depending who you ask

  • stored procedures and banks
  • When to use Stored Procedures instead of using any ORM with programming logic?
  • Any reason not to use stored procedures for every query?
  • and many others
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜