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

Is it possible to embed a parameter in the name of stored procedure that's called from within another sproc?

$
0
0
I have some code that I need to run every quarter. I have many that are similar to this one so I wanted to input two parameters rather than searching and replacing the values. I have another stored procedure that's executed from this one that I will also parameter-ize. The problem I'm having is in embedding a parameter in the name of the called procedure (exec statement at the end of the code). I tried it as I'm showing and it errored. I tried googling but I couldn't find anything related to this. Maybe I just don't have the right keywords. Is it possible? If so, what is the syntax? Thanks.[code="sql"]CREATE PROCEDURE [dbo].[runDMQ3_2014LDLComplete] [b]@QQ_YYYY char(7), @YYYYQQ char(8)[/b]ASbegin SET NOCOUNT ON;select [provider group],provider, NPI, [01-Total Patients with DM], [02-Total DM Patients with LDL],round(cast([02-Total DM Patients with LDL] as float)/[01-Total Patients with DM]* 100,2) as PercentLDLComplete, round(cume_dist() over ( order by round(cast([02-Total DM Patients with LDL]as float)/[01-Total Patients with DM]* 100,2) )*100,2) as CDist,YYYYQQfrom dbo.DMMeasures where [01-Total Patients with DM] > 0 and YYYYQQ = [b]@YYYYQQ[/b]order by round(cast([02-Total DM Patients with LDL]as float)/[01-Total Patients with DM]* 100,2) desc , CDist descendexec DM[b]@QQ_YYYY[/b]MT1[/code]parameter value examples: @YYYYQQ = '2014Q3' and @QQ_YYYY = Q3_2014

Viewing all articles
Browse latest Browse all 3145

Trending Articles