Z
Z
zhaar2019-02-21 10:54:17
SQL
zhaar, 2019-02-21 10:54:17

How to start a query execution from the result of another query?

Given:
There is a large select that was previously executed by hand, as a result it produces a set of lines that were enough to insert into the console and start execution (lines like exec xp_cmdshell 'BCP "..."')
Needed:
Actually, as the resulting canvas from exec 'ov run for execution immediately after the select, without copying it to the studio console?
I can write the results of the select to a live\tempo table.
Tried to do through the cursor, but unsuccessfully.
The entire result of the select can be run line by line or all at once, it does not matter

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zhaar, 2019-02-21
@zhaar

Suddenly, someone needs to
declare commands cursor for
SELECT * from table_name
declare cmd varchar(max)
open commands
fetch next from commands into @cmd
while @@FETCH_STATUS=0
begin
exec (@cmd)
fetch next from commands into @cmd
end
close
deallocate commands

K
Konstantin Tsvetkov, 2019-02-21
@tsklab

Temporary table .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question