stored procedure-multiple steps

  • create PROCEDURE [dbo].[CalChestSum]

    with recompile

    AS

    SET NOCOUNT ON

    begin

    declare @DateTo datetime

    delete from [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    go

    INSERT INTO [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    ([Indication]

    ,[IndicationC]

    )

    SELECT

    [The learner is able to understand chest tubes and indications for a chest insertion],

    Count( [The learner is able to understand chest tubes and indications for a chest insertion]) as FCount

    FROM [Clinical_Edu_2006].[dbo].[NursingFeedback] group by [The learner is able to understand chest tubes and indications for a chest insertion]

    go

    select * from [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    go

    end

    error:

    Msg 170, Level 15, State 1, Procedure CalChestSum, Line 27

    Line 27: Incorrect syntax near 'tblSChestTubeFeedback'.

    (4 row(s) affected)

    (4 row(s) affected)

    Msg 156, Level 15, State 1, Line 5

    Incorrect syntax near the keyword 'end'.

  • create PROCEDURE [dbo].[CalChestSum]

    with recompile

    AS

    SET NOCOUNT ON

    begin

    declare @DateTo datetime

    delete from [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    INSERT INTO [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    (

    [Indication]

    , [IndicationC]

    )

    SELECT [The learner is able to understand chest tubes and indications for a chest insertion]

    , Count([The learner is able to understand chest tubes and indications for a chest insertion]) as FCount

    FROM [Clinical_Edu_2006].[dbo].[NursingFeedback]

    group by [The learner is able to understand chest tubes and indications for a chest insertion]

    select *

    from [Clinical_Edu_2006].[dbo].[tblSChestTubeFeedback]

    END

  • You can't have GO statements within the procedure...

    And actually I don't see why you would need them in that case.

  • thanks.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply