Passing dynamic parameters to a stored procedure in SQL Server 2008
- by themhz
I have this procedure that executes another procedure passed by a parameter and its parameters datefrom and dateto.
CREATE procedure [dbo].[execute_proc]
@procs varchar(200),
@pdatefrom date,
@pdateto date
as
exec @procs @datefrom=@pdatefrom,@dateto=@pdateto
But I need to also pass the parameters dynamically without the need to edit them in the procedure. For example, what I am imagining is something like this
CREATE procedure [dbo].[execute_proc]
@procs varchar(200),
@params varchar(max)
as
exec @procs @params
where @params is a string like @param1=1,@param2='somethingelse'
Is there a way to do this?