我想将下面的查询结果保存到一个数据库表里面,怎么做,求高手指点啊~
select*from(selectdistinct[SellID]FROMQuery)AOUTERAPPLY(SELECT[ID]=STUFF(REPLACE(REPL...
select * 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
),'<N BookID="',','),'"/>',''),1,1,'')
)N
ORDER by [SellID] 展开
APPLY(
SELECT [ID]=STUFF(REPLACE(REPLACE(
(
SELECT [BookID] FROM Query N
where SellID=A.SellID
FOR XML AUTO
),'<N BookID="',','),'"/>',''),1,1,'')
)N
ORDER by [SellID] 展开
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
),'<N BookID="',','),'"/>',''),1,1,'')
)N
ORDER by [SellID]
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
),'<N BookID="',','),'"/>',''),1,1,'')
)N
ORDER by [SellID]
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询