Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Execute a stored procedure from a batch file Expand / Collapse
Author
Message
Posted Tuesday, October 12, 2010 11:14 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 8, 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
Posted Wednesday, October 13, 2010 7:06 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Friday, December 19, 2014 7:58 AM
Points: 5,370, Visits: 9,010
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
Posted Thursday, October 14, 2010 12:06 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Tuesday, May 8, 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
Posted Thursday, December 1, 2011 8:43 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, December 1, 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
Posted Friday, December 2, 2011 3:21 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 5:23 AM
Points: 1,522, Visits: 2,731
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 »

Add to briefcase

Permissions Expand / Collapse