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'.
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
Must declare the scalar variable "@studyId".
where you ahve declared @studyId ? is it passed as parameter to SP?
then check the syntax near that
where you ahve declared @studyId ? is it passed as parameter to SP?
then check the syntax near that
ASKER
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
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
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'.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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'.
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'.
ASKER
I remove all teh "GO"between begin and end of my sp and all the sytax error went away. Thank you
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'