Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using a variable in the FROM clause of a SELECT
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00877124
Message ID:
00877133
Views:
17
Any time ...

>Hi Sergey,
>
>Okay, that'll work. Didn't think about using that approach.
>
>Once again, you're quick and right on top of things. Many thanks...
>
>
>>T-SQL doesn't support variables in table names. You can use dynamic SQL instead.
DECLARE @sql varchar(4000)
>>SET @sql = 'update @chvTableName SET ClientID = ClientID + ' + CAST(@insClientOffset AS varchar(16)) +
>>', QuoteID        = QuoteID  + ' + CAST(@insQuoteOffset AS varchar(16)) +
>>', MasterClientID = MasterClientID + ' + CAST(@insMasterClientOffset AS varchar(16))
>>
>>EXECUTE (@sql)
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform