SQL Server essence

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

在SQL SERVER中,不要将变量和参数弄混淆了,即使他们的语法几乎相同:

1. 一个变量的值在一条SQL语句被真正执行之前永远是未知的,在编译时也是未知的。

2. 传递给存储过程的参数值在编译时是已知的,因为直到存储过程参数被赋值并且被真正调用,该存储过程才被编译和优化!

 

原文:

Don't confuse variables with parameters even though their syntax is nearly identical. A variable's value is never known until the statement is actually executed; it is never known at compile time. Stored procedure parameters are known when the procedure is compiled because compilation and optimization don't even take place until the procedure is actually called with specific values for the parameters.

posted on 2009-04-15 16:33  天蝎  阅读(246)  评论(0编辑  收藏  举报