Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Too many stored procedures

$
0
0
Hi all,I have hundreds of SPs and I was thinking that maybe I could do a SP that runs all of the other ones, instead of creating a separate job step for all of them.New SP's are still being developed and this would save me some time with not having to add new job steps withe the new SPs.This is my TEST code that would run the SPs. It's easy grab the SP name from [SP_Names] put it in a parameter and execute it, grab the second one and so on.[code="sql"]DECLARE @sp varchar(50)DECLARE @cnt INT = 1WHILE @cnt < (SELECT COUNT([SP_Names])+1 as SPs FROM [RISE_DATA].[dbo].[TEST])BEGIN SET @sp = (SELECT '[RISE_DATA].[dbo].' + [Names] as SPs FROM [RISE_DATA].[dbo].[TEST] WHERE [SP_Names] like '%' + CAST(@cnt as varchar(10)) + '%' ) EXEC (@sp) SET @cnt = @cnt + 1END[/code]I'm not sure if this is a good idea. I have my doubts about error handling. For example will the execution of the SPs stop if one of them fails? Or if more than one of them fails will I be able to see the error for all of them?I haven't done error handling before so I'm not sure about this whole thing. Does anyone have any suggestions or ideas how to make this work?

Viewing all articles
Browse latest Browse all 3145

Trending Articles