What is the difference between the following declarations:
DECLARE @id bigint and DECLARE @@id bigint
asked May 26 '10 at 10:59 AM in Default
There is no difference. The rules for variables state that they start with an '@' character and follow the rules for identifiers.
Since '@' is a valid identifier character, you can have as many as you like at the start of your variable name. However, if you match a system function which has the same name as your variable, then the query will not compile.
answered May 26 '10 at 11:10 AM
Matt Whitfield ♦♦
In previous versions of SQL Server @ described a local variable and @@ describe a global variable. Now (SQL 2008) @@ is used for a function name so @@ shouldnt be used as a parameter name.
Books OnLine ref http://msdn.microsoft.com/en-us/library/ms187953.aspx
answered May 26 '10 at 11:08 AM