Running Sql Script From C#?
-
HI! I have a sql script file(myscript.sql size 60k) When i run this script in a query analyzer it runs fine but when i makes its a Stored procedure so as i may be able to call it from my C# application. But sql doesnt allow me to amke a sp of it as it raises a lot of errors. Whats the real problem. I want to make this script a Stored Procedure so as i may be able to call it from my Application. Whats he solution to it. Should i be to remove all go Statements or anything else in sql Script.Or is there any other way round to do this. Solution required THNX In Advance
-
HI! I have a sql script file(myscript.sql size 60k) When i run this script in a query analyzer it runs fine but when i makes its a Stored procedure so as i may be able to call it from my C# application. But sql doesnt allow me to amke a sp of it as it raises a lot of errors. Whats the real problem. I want to make this script a Stored Procedure so as i may be able to call it from my Application. Whats he solution to it. Should i be to remove all go Statements or anything else in sql Script.Or is there any other way round to do this. Solution required THNX In Advance
majidbhutta wrote:
I want to make this script a Stored Procedure so as i may be able to call it from my Application
You don't have to make a SQL Script a Stored procedure in order to run if from a C# application. Any SQL can be put in the
CommandText
propery of aSqlCommand
.majidbhutta wrote:
Should i be to remove all go Statements or anything else in sql Script.
The
GO
is not SQL. It is a pre-processor command to Query Analyzer to tell it where to split the script into batches. When Query Analyzer encounters aGO
while processingCREATE PROCEDURE
statment it treats it as the end of the stored procedure. Everything after theGO
will be in a new batch and not the stored procedure - That is likely to be the cause of the error. ColinMackay.net Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?