首页 > 代码库 > sql 将查询的结果集一次性插入到表变量中
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) aselect * from @Subject
sql 将查询的结果集一次性插入到表变量中
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。