I can execute a dynamic SQL with the following, but the variable assignment
in the string isn't being assigned:
DECLARE @userID as nvarchar(10),
@myTable as nvarchar(10),
@strUser as nvarchar(100)
SET @myTable = 10659
SET @strUser = N'SELECT @UserID = UserID from my_' + @myTable +
'_user where UserLName = ''Smith'''
EXEC sp_executesql
@statement = @strUser
I get this error: Must declare the variable '@UserID', which is
understandable I guess.
Does anybody have any ideas for what I am trying to do?
Thanks!
/Keith
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Find out how CFTicket can increase your company's customer support
efficiency by 100%
http://www.houseoffusion.com/banners/view.cfm?bannerid=49
Message: http://www.houseoffusion.com/lists.cfm/link=i:6:2202
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/6
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:6
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.6
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54