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 - 2005-11-23 : 07:04:08
|
| Scott writes "Is it possible to use a variable in place of the server name within a cursor??declare @sqlserver varcharset @sqlserver='ABCDEFG'SELECT b.[originating_server],b.[name],a.step_name,a.output_file_name,a.last_run_outcome,a.last_run_date, a.last_run_time FROM @sqlserver.msdb.dbo.sysjobsteps AS a INNER JOIN @sqlserver.msdb.dbo.sysjobs AS b ON a.job_id = b.job_id" |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-23 : 07:16:02
|
| for this kind of query u need to write the dynamic sql.. declare @sqlserver varcharset @sqlserver='ABCDEFG'Exec ('SELECT b.[originating_server],b.[name],a.step_name,a.output_file_name,a.last_run_outcome,a.last_run_date, a.last_run_timeFROM ' +@sqlserver+'.msdb.dbo.sysjobsteps AS a INNER JOIN' + @sqlserver +'.msdb.dbo.sysjobs AS bON a.job_id = b.job_id')Hope this works for u .. Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-11-23 : 08:05:29
|
| provided that server is added as a Linked Server>>Is it possible to use a variable in place of the server name within a cursor??Why do you need Cursor?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|