Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Simon_L
Starting Member
32 Posts |
Posted - 2009-11-24 : 12:09:09
|
| After some wise words of wisdom ... Ive got this so far ....declare @linkedserver varchar(100), @dbname varchar(100), @destination varchar(500), @sqlstr varchar(1000)set @dbname = 'AdventureWorks'select @linkedserver = 'QAServer1'set @destination = @linkedserver+'.'+@dbname+'.'+'sales.'--print @destination select * from @destination+SalesOrderHeader Pjoin @destination+SalesOrderDetail Don p.salesorderID = d.salesorderIDI know the select does not work ... is there a way to get it to work without having to resort to dynamic sql for the whole statement ?set @sqlstr = 'select * from '+@destination+'SalesOrderHeader P join '+@destination+'SalesOrderDetail D on p.salesorderID = d.salesorderID'exec (sqlstr)thanks simon |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-24 : 13:18:37
|
server.dbname.schema(i.e. dbo).table No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Simon_L
Starting Member
32 Posts |
Posted - 2009-11-25 : 05:04:04
|
| hey fred ... yes the four oart naming isnt the issue it was an alterntaive (if one exists) to the dynamic sql I was wondering about ?thanks si |
 |
|
|
|
|
|