Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This script can connect to multiple servers, and try to find where a stored procedure is used
- --I'll clean it up eventually and add a loop for this but for now I wanted to share what I had
- --NOTE: You must turn on the SQLCMD command in SSMS to get this to work.
- --This is done in Query > SQLCMDMode (Its just a toggle in the menu)
- --Changes the connection in SSMS
- :CONNECT Server01 --CHANGE THIS
- go
- SELECT j.name
- FROM msdb.dbo.sysjobs AS j
- WHERE EXISTS
- (
- SELECT 1 FROM msdb.dbo.sysjobsteps AS s
- WHERE s.job_id = j.job_id
- AND s.command LIKE '%StoredProcedure%' --CHANGE THIS
- );
- SELECT @@SERVERNAME --Lets us know we've got the right one
- go
- :CONNECT Server02 --CHANGE THIS
- go
- SELECT j.name
- FROM msdb.dbo.sysjobs AS j
- WHERE EXISTS
- (
- SELECT 1 FROM msdb.dbo.sysjobsteps AS s
- WHERE s.job_id = j.job_id
- AND s.command LIKE '%StoredProcedure%' --CHANGE THIS
- );
- SELECT @@SERVERNAME
- go
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement