Incorrect syntax near the keyword 'as'. while set the value for variable
-
Saturday, January 19, 2013 9:55 AM
declare @Date as datetime declare @c as int select @Date='01/17/2013' select @c = PD.copies as 'PD_COPIES' from PHeader PH inner join PDetailsPD on PH.Po_id=Pd.PD_Po_id
Hi what s wrong here
here i am getting error 'Incorrect syntax near the keyword 'as'.
adil
All Replies
-
Saturday, January 19, 2013 10:08 AM
Try
select @c = PD.copies from PHeader PH inner join PDetailsPD on PH.Po_id=Pd.PD_Po_id
Serg
- Proposed As Answer by Naomi NMicrosoft Community Contributor, Moderator Sunday, January 20, 2013 5:05 AM
- Marked As Answer by Iric WenModerator Monday, January 28, 2013 6:03 AM
-
Saturday, January 19, 2013 1:22 PM
When assiging a value to a variable the variable already has a name , since the action is assigning a value and not output you cant give the variable an alias
Jayanth Kurup - www.enabledbusiness.com
- Proposed As Answer by Olaf HelperMicrosoft Community Contributor Sunday, January 20, 2013 8:47 AM
-
Sunday, January 20, 2013 5:06 AMModerator
If you're using a scalar variable to return the result you need to remove AS AliasName part from your query, e.g.
select @c = PD.copies from PHeader PH inner join PDetailsPD on PH.Po_id=Pd.PD_Po_id
For every expert, there is an equal and opposite expert. - Becker's Law
My blog

