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

lapuccaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Pratima PharandeCommented:
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'

0
Pratima PharandeCommented:
Must declare the scalar variable "@studyId".

where you ahve declared @studyId ? is it passed as parameter to SP?
then check the syntax near that
0
lapuccaAuthor Commented:
Hi, attached is my code.  thank you
@studyId is declare as a paramenter to the sp
CreateAccount.sql
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

Pratima PharandeCommented:
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
0
lapuccaAuthor Commented:
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'.
0
Pratima PharandeCommented:
try this is it working

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
BEGIN
      -- SET NOCOUNT ON added to prevent extra result sets from
      -- interfering with SELECT statements.
      SET NOCOUNT ON;

-- Insert into Patient table
INSERT INTO [AdaptSurvey].[dbo].[Patients]
           ([StudyId]
           ,[CompletedImpForm]
           ,[DoctorId]
           ,[DateOfFirstVisit]
           ,[Active])
     VALUES
           (@studyId
           ,0
           ,@doctorId
           ,@officeDate
           ,1)
GO
end
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lapuccaAuthor Commented:
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'.
0
lapuccaAuthor Commented:
I remove all teh "GO"between begin and end of my sp and all the sytax error went away.  Thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.