Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Expand a variable in line?
Message
From
27/12/2000 15:30:29
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Title:
Expand a variable in line?
Miscellaneous
Thread ID:
00457150
Message ID:
00457150
Views:
55
is there any way to expand a variable in line in a select statement without having to do the whole dang thing in dynamic sql? what I would like is:
declare @database varchar(32), @field char(20)
set @database = 'mydatabase'

select @field = myfield from @database .dbo.sometable
but of course- this doesn't work - I can do it in dynamic SQL, but then the var @field isn't avaialble in the calling procedure.

Is there any way just to imbed the variable in the select statement or otherwise pull this off without having to go to temp tables?

Thanks,
Ken
Ken B. Matson
GCom2 Solutions
Next
Reply
Map
View

Click here to load this message in the networking platform