Link to home
Start Free TrialLog in
Avatar of lapucca
lapucca

asked on

What's wrong with my sp?

Here the            ,[CompletedImpForm] and [DateOfFirstVisit are bit type.  I'm getting the following errors but @studyId is a int paramenter while in the table it is a PK int type.  How can I fix this?  Thank you.
Msg 102, Level 15, State 1, Procedure CreateNewAccount, Line 29
Incorrect syntax near ')'.
Msg 137, Level 15, State 2, Line 7
Must declare the scalar variable "@studyId".
Msg 137, Level 15, State 2, Line 9
Must declare the scalar variable "@studyId".
Msg 137, Level 15, State 2, Line 8
Must declare the scalar variable "@studyId".
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'END'.
INSERT INTO [AdaptSurvey].[dbo].[Patients]
           ([StudyId]
           ,[CompletedImpForm]
           ,[DoctorId]
           ,[DateOfFirstVisit]
           ,[Active])
     VALUES
           (@studyId
           ,0
           ,@doctorId
           ,@officeDate
           ,1)
GO

Open in new window

Avatar of Pratima
Pratima
Flag of India image

As per the synatx Inser into syntax looking ok

but erro is
Incorrect syntax near 'END'

So can you share whole procedure ? might be you havn't start the end the bign properly .
Where your have used 'End'

Must declare the scalar variable "@studyId".

where you ahve declared @studyId ? is it passed as parameter to SP?
then check the syntax near that
Avatar of lapucca
lapucca

ASKER

Hi, attached is my code.  thank you
@studyId is declare as a paramenter to the sp
CreateAccount.sql
You missee the paranthesis

try like this

CREATE PROCEDURE usp_CreateNewAccount
      -- Add the parameters for the stored procedure here
(      @studyId int, @doctorId int, @officeDate DateTime, @numStepsGoal int,
      @dietGoalOptionId int, @targetNumber int, @aPExerciseOptionsId int, @otherExercise nvarchar(300)
      
)
AS
Avatar of lapucca

ASKER

duh.. but I added the parenthesis and still got the errors
CREATE PROCEDURE usp_CreateNewAccount
      -- Add the parameters for the stored procedure here
      (@studyId int, @doctorId int, @officeDate DateTime, @numStepsGoal int,
      @dietGoalOptionId int, @targetNumber int, @aPExerciseOptionsId int, @otherExercise nvarchar(300))
      
AS

-----------------------
Msg 102, Level 15, State 1, Procedure usp_CreateNewAccount, Line 29
Incorrect syntax near ')'.
Msg 137, Level 15, State 2, Line 7
Must declare the scalar variable "@studyId".
Msg 137, Level 15, State 2, Line 9
Must declare the scalar variable "@studyId".
Msg 137, Level 15, State 2, Line 8
Must declare the scalar variable "@studyId".
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near 'END'.
ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of lapucca

ASKER

I copy your whole code and replace the sp with just that and still got the following error
Msg 102, Level 15, State 1, Procedure usp_CreateNewAccount, Line 26
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'end'.
Avatar of lapucca

ASKER

I remove all teh "GO"between begin and end of my sp and all the sytax error went away.  Thank you