[Solved] How to create a stored procedure for select/update/delete statements


As David said you are almost there but just need minor changes.

  1. I suppose @Pid is a parameter,if so, it is missing from the Stored Procedure defintion.
  2. The (and specialistId=@Pid and iscompleted =1) form the Where clause (Filter expression). So the procedure goes like this

`

CREATE PROCEDURE PROCD1 (@PID INT )
AS 
    BEGIN
        SELECT  CONVERT(VARCHAR,RTRIM(l.Lab1)) + "https://stackoverflow.com/" + CONVERT(VARCHAR,RTRIM(l.LabR)) AS Lab ,
                meta.Title ,
                la.[ID] ,
                ls.[surveyID] ,
                ls.[specialistID] ,
                ls.[isCompleted]
        FROM    [MyDIM].[dbo].[lsLabSurvey] ls
                INNER JOIN [MyDIM].[dbo].[dimDocMetaInfo] meta ON meta.id = ls.[surveyID]
                INNER JOIN MyDatabase.DBO.PID_Table l ON ls.ID = l.ID
        WHERE   ls.specialistID = @PID
                AND ls.isCompleted = 1
    END 
`

Hope this helps.

1

solved How to create a stored procedure for select/update/delete statements