General information
Forum:
Microsoft SQL Server
I think whats happening is the exec function doesn't know what the variable means. If you enclosed the declare statement within the exec the statement it would probably execute. You would however not be able to use the result as it think it would be destoryed upon completion. The only way i can think of working round this is to output the result into a global temp table using a select into (if permitted on you sql sqrver check options!!). The result could then be read by a simple
select @variable = field1 from ##temptable.
Ive noticed that the thread is quite old so if you have already solved this accept my appologies.
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only