在存储过程代码

时间:2017-04-14 12:58:33

标签: sql stored-procedures

我是sql的新手。我有一个存储过程,我需要添加两个列,这些列是表" dbo.AdditionProjectDetails"。这里ProjectID是主键。下面是代码片段,因为我无法在此处添加整个代码段。有什么帮助吗?

    SELECT  PBD.Proj_ID, case when Phase =1 then 'Phase I' when Phase=2 then 'Phase II'
                    Tasktype,Area_Name,ProjectName,OS_Name,PTCDD.Remarks 
                     FROM ProjectDetails (NOLOCK) PBD
                    inner join ProjectTestProcessDetails (NOLOCK) PTPD on PBD.Proj_ID =PTPD.Proj_ID
                    inner join ProjectTestCycleDet (NOLOCK) PTCD on PTCD.Proj_ID=PBD.Proj_ID
                    inner join ProjectTestCycleDuration (NOLOCK) PTCDD on PTCDD.Proj_ID=PBD.Proj_ID
                    inner join ProjectTestProcessCostDetails (NOLOCK) PTPCD on PTPCD.Proj_Test_PrepareID=PTPD.Proj_Test_PrepareID
                    inner join AreaMaster Am on Am.Area_ID =PBD.AreaID
                    inner join ProjectMaster PM on PM.ProjectID =PBD.PlatformID
                    inner join OSMaster OS on OS.OS_ID =PBD.OSID

                    where Status in ('S','R','C') and Tasktype,Area_Name,ProjectName,OS_Name,PTCDD.Remarks
group by PBD.Proj_ID,PBD.Created_by,PBD.Created_on,status,TaskGivenDate
                    order by PTCD.TaskEndDate DESC

1 个答案:

答案 0 :(得分:0)

在这里查看此链接是对商店程序的解释,并详细说明您想要的内容

Insert results of a stored procedure into a temporary table

T-SQL How to create tables dynamically in stored procedures?