我想将下面的查询结果保存到一个数据库表里面,怎么做,求高手指点啊~

2025-01-05 11:47:53
推荐回答(1个)
回答(1):

select *
into [DataTable] --[DataTable]为你想要储存数据的表名。直接插入就可以了,自动创建这个表的
from (select distinct [SellID] FROM Query) A OUTER
APPLY(
SELECT [ID]=STUFF(REPLACE(REPLACE(
(
SELECT [BookID] FROM Query N
where SellID=A.SellID
FOR XML AUTO
),'',''),1,1,'')
)N
ORDER by [SellID]