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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-11-30 : 09:28:25
|
| Pavan writes "Hi! AllI want to execute a dynamic sql in which i am inserting a records from a select statment to a temporary table.My select statment will select a records from a link server database. Here the Links server database name is store in a table. So i will be getting it from the table and depending upon the value i want to execute the sql statment to that server.here is my codealter procedure p_tempasBEGINset nocount ondeclare @st1 varchar(50)declare @st2 varchar(1000)declare @st3 varchar(1000)declare @t_t (c0 varchar(100),c1 int ,c2 varchar(100),c3 varchar(100))select @st3= "Insert @t_t select 'Fixed value', c2,c3,c3from Linked_server..user.tablename "/* Here i want tthe Linked server should be varying from time to time. e.g select @t=linkservername from table1 where c1='34'select @st3= "Insert @t_t select 'Fixed value', c2,c3,c3from @t..user.tablename "*/print @st3print 'go'select * from @t_tEND" |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|