SQL语句 怎样取出Exec执行得到的数据集

2025-03-01 13:07:27
推荐回答(2个)
回答1:

用临时表,如:

CREATE TABLE #tmp_table1
(
Column1 VARCHAR(1) NULL
)

INSERT INTO #tmp_table1
EXEC ('SELECT * FROM table1')

DECLARE cur_table1 CURSOR FOR SELECT * FROM #tmp_table1
--...

回答2:

Exec('Select column 【into #temp】 from Table ')

declare cur cursor for
SELECT column FROM #temp