I need to write a procedure which will have just execute statements.
Example:
Create Procedure dbo.allSPExecute( @id int)
as
begin
EXEC dbo.tic @day= 7,@name = 'Gname',@Type = 'Utype'
EXEC dbo.tic @day= 7,@name = 'tname',@Type = 'Utype'
EXEC dbo.gtype @day = 7,@Tname = 'UName_By',@Udept = 'Dept'
End
I have more than 50 statements like this.I have a Table which is Lookup:
ID Name SCol Dcol IOrd
1 dbo.tic Gname @name 1
1 dbo.tic tname @name 2
1 dbo.tic Utype @Type 1
1 dbo.tic Utype @Type 2
2 dbo.gtype UName_By @Tname 1
2 dbo.gtype Dept @Udept 1
Is there a way so that If i pass ID then it will take the values from the Lookup table and execute the procedure. Can anyone help?
EDIT: Changed the Data from Lookpup table and Create Procedure
here is a solution that does not need cursors. I am using FOR XML keyword to concatenate strings together. I am doing this in two places – once for concatenating the list of parameters, and once for concatenating all the individual exec statements. I haven’t tested this though, but i think this should be much faster than using cursors