[SQL] Generate Multiples Rows of Execution Query

I needed to run few hundreds rows of records and it is very troublesome when I have to change the ID for each time I execute a command. I was taught to write out the command in this way:-

select ‘DECLARE @i INT DECLARE @s VARCHAR(200) EXEC [dbo].[adm_sp_coin_adjust2]  ‘ +
””+PassportID+”’, ”liyen”, ”127.0.0.1”, @i output, @s output ‘ from dbo.MFlist

It grabs all the IDs from the table and the output from the above syntax will be the hundreds rows of records that are ready to be executed. It is really amazing.

Leave a comment