sp help -error on sp

  • CREATE PROCEDURE [dbo].[GetChestTube]

    @DateFrom datetime='09/04/05',

    @DateToIn datetime='03/04/06',

    @cc varchar(50)

    with recompile

    AS

    SET NOCOUNT ON

    begin

    declare @DateTo datetime

    select @DateTo = @DateToIn+1

    SELECT distinct h.[FULL NAME], h.[DOB], h.CC

    FROM annual_edu_2006.dbo.HREMP h WHERE h.HREMP.CC=@CC inner JOIN

    (SELECT [Employee Name],DOB

    FROM [NursingFeedBack] where [Submit Time] >= @DateFrom and [Submit Time] <= @DateTo )
    [b]x [/b]ON h.[Full Name]=x.[Employee Name] and h.[DOB]=x.[DOB]

    I do not know why I get this error:

    Msg 156, Level 15, State 1, Procedure GetChestTube, Line 17
    Incorrect syntax near the keyword 'inner'.
    Msg 170, Level 15, State 1, Procedure GetChestTube, Line 20
    Line 20: Incorrect syntax near 'x'.

  • Your format is wrong.

    select a

    from tableA

    inner join Table B

    on a.x = b.x

    WHERE a.y = 1

    The joins come before the WHERE.

Viewing 2 posts - 1 through 1 (of 1 total)

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