April 17, 2007 at 11:21 pm
Hi All
I was wondering if some1 would know if possible at all how to create a alias name for a database or use a database like a variable. Like alias's for tables example. Database01 as [ClientDatabase]
or SET Database01 = @DatabaseVaraible ( wishfull thinking....)
thanks
l0n3i200n
April 18, 2007 at 2:32 pm
That would be sweet, as would a way to alias server names, and even table and column names, so that four-part notation could read: select * from @server.@database.@table.@column.
There is no way to do this directly, however, so we're stuck with using "dynamic SQL", with its lack ownership chaining:
exec('select * from ' + @server +'.' + @database + '.' + @table + '.' + @column)
If there are parameters involved, use sp_executesql instead (see BOL).
Ron Rice
April 18, 2007 at 10:24 pm
Thought so ... just wanted to be proofed wrong. Thanks for the reply thou.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply