FALCONSEYE
Programmer
i have the following
declare @myResult int
set @myResult =
exec ('Select Sum(numShipped) as numshipped from ' + @txtTableName
+ ' Where Shipdate = (Select max(shipdate) from myTable)')
i also tried
exec ('Select Sum(numShipped) as numshipped from ' + @txtTableName
+ ' Where Shipdate = (Select max(shipdate) from myTable)') as @myResult
for some reason, the exec statement runs fine by itself. when i try to assign the result of the exec statement to a variable sql throws an error. does anyone know how to set a variable from an exec statement?
thanks for the help in advance..
declare @myResult int
set @myResult =
exec ('Select Sum(numShipped) as numshipped from ' + @txtTableName
+ ' Where Shipdate = (Select max(shipdate) from myTable)')
i also tried
exec ('Select Sum(numShipped) as numshipped from ' + @txtTableName
+ ' Where Shipdate = (Select max(shipdate) from myTable)') as @myResult
for some reason, the exec statement runs fine by itself. when i try to assign the result of the exec statement to a variable sql throws an error. does anyone know how to set a variable from an exec statement?
thanks for the help in advance..