Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
Programming
»
General
»
Execute a stored procedure from a batch file
Execute a stored procedure from a batch file
Rate Topic
Display Mode
Topic Options
Author
Message
nivecse
nivecse
Posted Tuesday, October 12, 2010 11:14 PM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, May 08, 2012 8:43 AM
Points: 139,
Visits: 66
Hi,
I have to execute an SP from .bat file. What I have done is, I have created a .bat file with the following entry:
%OpMode% %msISQL% Some_File.sql
The "Some_File.sql" file contains the following execute statement:
execute [dbo].[Stored_Proc_Name] 1,0,0,''
The connection parameters for the database are in another .bat file.
When I execute the .bat file, am getting the following error:
Msg 170, Level 15, State 1, Server SERVER_NAME, Line 1
Line 1: Incorrect syntax near 'ÿ'.
Any help is appreciated..
Thanks,
Nivetha
Post #1003355
WayneS
WayneS
Posted Wednesday, October 13, 2010 7:06 AM
SSCertifiable
Group: General Forum Members
Last Login: Yesterday @ 2:02 PM
Points: 6,367,
Visits: 8,228
I would suspect that the line you're executing isn't correct.
Try putting an "echo %OpMode% %msISQL% Some_File.sql" to ensure that it's being called properly (you may need a "pause" in there also).
Wayne
Microsoft Certified Master: SQL Server 2008
If you can't explain to another person how the code that you're copying from the internet works, then
DON'T USE IT
on a production system! After all,
you
will be the one supporting it!
Links:
For better assistance in answering your questions
,
How to ask a question
,
Performance Problems
,
Common date/time routines
,
CROSS-TABS and PIVOT tables Part 1
&
Part 2
,
Using APPLY Part 1
&
Part 2
,
Splitting Delimited Strings
Post #1003576
nivecse
nivecse
Posted Thursday, October 14, 2010 12:06 AM
SSC-Enthusiastic
Group: General Forum Members
Last Login: Tuesday, May 08, 2012 8:43 AM
Points: 139,
Visits: 66
Hi,
Am getting the following entry in my log file when i put echo before
%OpMode% %msISQL% Some_File.sql:
CALL C:\sql\core\MS_ISQL_Driver.bat Some_File.sql
executing MS_ISQL_Driver.bat with input file Some_File.sql
---- START ERROR HANDLING -----
BATCH TERMINATED by unexpected error "in SQL Script Some_File.sql". Skipping remaining batch.
I think there is problem with the Some_File.sql, means, my way of executing the stored procedure might be wrong..
I have entry as:
execute [dbo].[Stored_Procedure_Name] 1,0,0,''
Is this right?
Post #1004143
jregan 3066
jregan 3066
Posted Thursday, December 01, 2011 8:43 AM
Forum Newbie
Group: General Forum Members
Last Login: Thursday, December 01, 2011 8:41 AM
Points: 1,
Visits: 0
I have the same error message. I am running a batch file that calls a SQL file that runs a pretty simple update script. When I run the script manually, it runs fine. The same syntax that applies to the call to this script is used to call multiple other scripts on a nightly basis, and the others all work. Here is the error message (which I know is not very helpful by itself):
Incorrect syntax near 'ÿ'.
Like I said, the same batch file contains calls to 6 SQL scripts, all with the same credentials and syntax.
Post #1214695
WILLIAM MITCHELL
WILLIAM MITCHELL
Posted Friday, December 02, 2011 3:21 PM
UDP Broadcaster
Group: General Forum Members
Last Login: Tuesday, May 14, 2013 6:45 AM
Points: 1,441,
Visits: 2,485
Are you actually getting the lowercase y with the two little dots over it?
If so, your sql file is saved in Unicode, not standard ASCII. Open the sql file in SSMS, click file ~ save as, and then on the Save button click the little down-arrow at the right - select "save with encoding" and then select 1252 and then you can save it in ASCII.
Post #1215718
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.