sql 将查询的结果集一次性插入到表变量中
Posted zhyue93
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 将查询的结果集一次性插入到表变量中相关的知识,希望对你有一定的参考价值。
declare @Subject table (--题目表变量 SubjectID int, Question nvarchar(MAX), CorrectAnswer varchar(100), Explain nvarchar(MAX), SubjectTypeID int, CreateID int, CreateDate datetime, SubjectScore decimal(3, 1), ScoreSort int ) insert into @Subject(SubjectID,Question,CorrectAnswer,Explain,SubjectTypeID,CreateID,CreateDate,SubjectScore,ScoreSort) select a.SubjectID,a.Question,a.CorrectAnswer,a.Explain,a.SubjectTypeID,a.CreateID,a.CreateDate,a.SubjectScore,a.ScoreSort from (--题目表(传入参数 HistPaperID,subjecttitleid) select a.SubjectID,Question,Answer as CorrectAnswer,Explain,TypeID as SubjectTypeID,a.CreateID,CreateDate,Score as SubjectScore,Sort as ScoreSort from HistPaperSubject a left join HistPaperSubjectScore b on a.subjectID=b.subjectID where a.isdel=0 and a.HistPaperID=60 and b.HistPaperID=60 and b.subjecttitleid=193) a select * from @Subject
以上是关于sql 将查询的结果集一次性插入到表变量中的主要内容,如果未能解决你的问题,请参考以下文章
将一个表的查询结果插入到另一个表中(oracle、mysql、sql 、GP)