Solved

Error running Sql script in win app

Posted on 2008-10-09
12
1,974 Views
Last Modified: 2013-11-16
i get error message when i try to run my Sql script in my win app form.....

i get exception message saying thath:

'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
Incorrect syntax near the keyword 'PROCEDURE'.
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Account_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Balance".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Account_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Type_Id".
Must declare the scalar variable "@Type_Id".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@FileType_ID".
Must declare the scalar variable "@FileType_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@ImpFile_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Engagement_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Reconciled_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@ReconType_ID".
Must declare the scalar variable "@ReconType_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Client_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Setting_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@MatchItem_ID".
Incorrect syntax near the keyword 'PROCEDURE'.
Must declare the scalar variable "@Type_ID".
Must declare the scalar variable "@Type_ID".
a USE database statement is not allowed in a procedure, function or trigger.
a USE database statement is not allowed in a procedure, function or trigger.

Do somone now how to fix this problom?
0
Comment
Question by:Adnan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677125
your are trying to create a procedure from your windows application
can you share your sql that you send from your windows application
0
 

Author Comment

by:Adnan
ID: 22677161
oki, the script is very big, i am atachied the script. the script is for seting up the database for kustomer running ouer win app...!
0
 
LVL 26

Accepted Solution

by:
Anurag Thakur earned 500 total points
ID: 22677195
yes agreed the script is very big
i am assuming that you are trying to create the db through the application
i couldnt find out where but somewhere there is a GO missing
'CREATE/ALTER PROCEDURE' must be the first statement in a query batch.
normally comes if you have a normal statement like drop procedure and in the very next line you have a create procedure
maybe what i have explained will help you out or may be give you some direction to look for exception
0
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 

Author Comment

by:Adnan
ID: 22677218
if i use Go in my script i get exception inncorect syntax near 'Go'...........
0
 

Author Comment

by:Adnan
ID: 22677268
Incorrect syntax near 'go'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
Incorrect syntax near 'GO'.
Incorrect syntax near 'GO'.
Incorrect syntax near the keyword 'SET'.
0
 

Author Comment

by:Adnan
ID: 22677275
if i run the script direct in sql server then it run ok, but not true the application...
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677286
found the issue
search for this
CREATE PROCEDURE [dbo].[RestoreAccess]

the above procedure and a lot of procedures are not being created as the procedures before that and you are getting error around this line i think

your create procedure line should be like this and not as its in the script file
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[InsertMatchItemXtra]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N''
End
0
 

Author Comment

by:Adnan
ID: 22677322
oki, but i dident understand how i can fin my procedure......can you show me how nad what you are meaning by creating procedure like u sayd?
0
 
LVL 26

Expert Comment

by:Anurag Thakur
ID: 22677897
search for text create procedure in your script file and where create procedure does not preceed with the text as i mentioned in my previous comment you will have to make changes
I think all the procedures after the procedure CREATE PROCEDURE [dbo].[RestoreAccess] were like that (if i remember correctly)
0
 

Author Comment

by:Adnan
ID: 22678198
sorry ragi0017 i still do not understand, iam not so god in scripting and Database..... :(
0
 

Author Closing Comment

by:Adnan
ID: 31504595
i made it... ;) thanks for helping...u guide me the right way
0
 
LVL 1

Expert Comment

by:modus_operandi
ID: 22787737
Sample file removed.
 
modus_operandi
EE Moderator
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question