I'd like at tool/script that would automatically substitute the calls to stored procedures with the code. It is better to explain with an example.
I have a code like this where a stored procedure is called twice
declare @x int, @y int
set @x = 10
exec @y = calculate_and_insert @x
set @x = @y
exec @y = calculate_and_insert @x
the called procedure has a code like:
create stored procedure calculate and insert @in int
as
declare @x int
set @x = 10
return @x + @in
See that it has a variable with the same name of one in the outer scope
I'd like to generate something like:
declare @x int, @y int
set @x = 10
declare @cai1_in int
set @cai1_in = @x
declare @cai1_x int
set @cai1_x = 10
set @y = @cai1_x + @cai1_in
set @x = @y
declare @cai2_in int
set @cai2_in = @x
declare @cai2_x int
set @cai2_x = 10
set @y = @cai2_x + @cai2_in
Maybe somebody already needed to do something like it. The reasoning is that I have a lot of stored procedures that I don't want to change in production, but I'd like to execute a new version of them to see the result. I'd recode them in test and generate a script.
I don't have to be done through SQL, can be done in another language. It also don't have to cover all cases.