T sql question

Archived from the original Sajha.com — preserved as posted, replies can no longer be added here.
Start a New Discussion
Archived Post

How can I do this? I want to create a store proc which execute the result of: Select name from sysjobs where name like 'myjobABC%' Another words, just say the result of above is name = "myjobABC02018" then I want EXEC dbo.sp_start_job 'myjobABC02018'

spring123 · Jul 27, 2018 11:41 AM · 14,576 views

1 Reply

Hey @spring123, Try this:- CREATE PROCEDURE dbo.sp_start_job @name nvarchar(30) AS Select name from sysjobs where name = @name Go EXEC dbo.sp_start_job 'myjobABC02018'; GO OR(using wildcard) CREATE PROCEDURE dbo.sp_start_job  @name nvarchar(30) AS Select name from sysjobs where name Like + @name +'%' Go EXEC dbo.sp_start_job 'myjobABC%';  GO Last edited: 27-Jul-18 02:45 PM

phone · Jul 27, 2018 2:29 PM

This conversation is preserved exactly as it was on the original Sajha.com and can't accept new replies.

Start a New Discussion