首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

关于信息安插临时表的信息

2013-10-11 
关于信息插入临时表的信息小弟想写一个存储过程。。。~里面有个临时表。它的参数有create table #t ( studenti

关于信息插入临时表的信息
小弟想写一个存储过程。。。~里面有个临时表。它的参数有create table #t ( studentid nvarchar(36),PKEstimateProjectID nvarchar(2000))
studentid --学生GUID
PKEstimateProjectID  --学生所需评估课程ID

想要的结果是这样的。
studentid   PKEstimateProjectID 
123          01
123          02
123          03
123          04
 

其中  studentid 是C#后台传入的GUID,就只有这一个学生的GUID。
PKEstimateProjectID 是
select d.PKEstimateProjectID
   from estimate_project d,(  select a.PKSemesterCourseID
   from semester_course_ships a ,(  select PKCourseID
   from estimate_course where FKClassTypeID ='85d75476-d5e3-420b-a7dc-112f6f470534') b
   where a.FKCourseID = b.PKCourseID) f where d.FKSemesterCourseID =f.PKSemesterCourseID order by FKAbilityProjectID 
这一段SQL查询到的信息。
  我如何写~~这个语句 去吧这两个参数 写入到#t中。~~~~想破头皮了~~还望大神指导。。这个语句怎么写。~~
存储 select sql c#
[解决办法]

insert into #t
select 
studentid  =123
,PKEstimateProjectID =
select d.PKEstimateProjectID
   from estimate_project d,(  select a.PKSemesterCourseID
   from semester_course_ships a ,(  select PKCourseID
   from estimate_course where FKClassTypeID ='85d75476-d5e3-420b-a7dc-112f6f470534') b
   where a.FKCourseID = b.PKCourseID) f where d.FKSemesterCourseID =f.PKSemesterCourseID order by FKAbilityProjectID
 
[解决办法]
insert into #t(studentid ,PKEstimateProjectID)
select @前端传入的学生GUID,d.PKEstimateProjectID
   from estimate_project d,(  select a.PKSemesterCourseID
   from semester_course_ships a ,(  select PKCourseID
   from estimate_course where FKClassTypeID ='85d75476-d5e3-420b-a7dc-112f6f470534') b
   where a.FKCourseID = b.PKCourseID) f where d.FKSemesterCourseID =f.PKSemesterCourseID order by FKAbilityProjectID 


难点只是如何获取那个GUID而已

热点排行
Bad Request.