What is the difference between @@ and @ in sql server? [Resolved]

Posted by Vivekjj under Sql Server on 10/5/2012 | Points: 10 | Views : 2079 | Status : [Member] | Replies : 5
any one can say wat is the difference between @@ and @




Responses

Posted by: Vasanthmvp on: 10/16/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi,
@variablename is a variable to hold some value depending on its type and range.
@@ refers to a function name.We have some system functions defined in sql server.. they perform operations on and return information about values, objects, and settings in SQL Server.

Eg: @@ERROR
@@IDENTITY
@@PACK_RECEIVED
@@ROWCOUNT
@@TRANCOUNT

To know about the above functions in detail refer :
http://technet.microsoft.com/en-us/library/ms187786.aspx

Awesome Coding !! :)

Vivekjj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pgayath on: 10/5/2012 [Member] Starter | Points: 25

Up
0
Down
hi Vivekjj,

Prior to SQL Server 2008, @ denotes a local variable and @@ denotes a global variable.
In SQL 2008, @@ refers to a function name and hence cannot be used for a parameter name.

Thanks and Regards,
Gayathri P

Vivekjj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sourabh07 on: 10/16/2012 [Member] Starter | Points: 25

Up
0
Down
hi ,

@@ represents the global variables i.e. used for the system functions in the SQL
and @ represents the local variable

eg:

1) Declare @id int (local variable)
2) @@identity , @@RowCount and many more (global variables)




Sourabh07

Vivekjj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vivekjj on: 10/30/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks for ur reply it very helpful

Vivekjj, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vasanthmvp on: 10/30/2012 [Member] Starter | Points: 25

Up
0
Down
Hi vivekjj, if it is helpful to you please mark it as answer.. it would be helpful to others.
Regards,

Awesome Coding !! :)

Vivekjj, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response