Answered by:
Declare variables-Tsql

Question
-
what is the difference if you give the parameter like this
@paramtername vachr(100) and @_parametername vacrhar(100).
Thanks,
Maverick
Thursday, December 6, 2012 10:48 PM
Answers
-
Well, one variable will be called @parametername and the other will be called @_parametername. Neither will have a valid datatype -- you probably mean "varchar" instead of "vachr" or "vacrhar".
- Proposed as answer by Uwe RickenMVP Friday, December 7, 2012 11:32 AM
- Marked as answer by Iric Wen Monday, December 17, 2012 6:37 AM
Thursday, December 6, 2012 10:51 PM
All replies
-
Well, one variable will be called @parametername and the other will be called @_parametername. Neither will have a valid datatype -- you probably mean "varchar" instead of "vachr" or "vacrhar".
- Proposed as answer by Uwe RickenMVP Friday, December 7, 2012 11:32 AM
- Marked as answer by Iric Wen Monday, December 17, 2012 6:37 AM
Thursday, December 6, 2012 10:51 PM -
different in what way? apart of syntax errorThursday, December 6, 2012 11:17 PM
-
If they are syntactically correct, both will be different variables.
Thursday, December 6, 2012 11:22 PM -
Both will be treated as different variables.
@paramtername vachr(100) and @_parametername vacrhar(100).
But please make sure you have the correct data type defined. I think you have a typo in the data type specified. It should be
@paramtername varchar(100) and @_parametername varchar(100).
Please mark as helpful and propose as answer if you find this as correct!!! Thanks, Rakesh.
Friday, December 7, 2012 4:50 AM -
Difference is they are different variable.Please make sure your datatype spelling varchar(100).
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
Friday, December 7, 2012 6:57 AM -
Hi Maverick,
Difference is that they are two Variables with same data type and same length.
Actually @ Sign is used to declare variable in SQL Server and as per your example both are starting with @ sign .
Please have a look on below link for complete description.
http://msdn.microsoft.com/en-us/library/aa258839%28v=sql.80%29.aspx
Thanks,
Please use Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful.
Regards, Randhir
Friday, December 7, 2012 9:18 AM -
Just because everyone seems to be answering the question with the same answer, I'll join in the fun.
Variable names can begin with a letter or an underscore, this is a standard. So you'll have two variables. @parametername and @_parametername.
Also, not that you probably don't know already, but you've spelt "VARCHAR" wrong.
Friday, December 7, 2012 9:55 AM