Hi guys,
Got the following bit of code throwing a syntax error but no idea why....
error is
''Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'select'.''
any ideas whats up with it? the count 'statement' runs fine on its own - just wont let me set the variable to be taht.
Having same problems when trying to update a table row to be the same.
Cheers,
Dan.
Got the following bit of code throwing a syntax error but no idea why....
Code:
declare @total int
set @total = select count(distinct member_ref)
from membership_history
where member_ref in (select member_ref from member where member_status = 33)
and datename(m,valid_from) = datename(m,dateadd(m,-1,getdate()))
error is
''Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'select'.''
any ideas whats up with it? the count 'statement' runs fine on its own - just wont let me set the variable to be taht.
Having same problems when trying to update a table row to be the same.
Cheers,
Dan.