RaghuS
RaghuS

Reputation: 103

input line is too long.the syntax of command is incorrect in batch file when trying to execute SQL query using BCP utility

I have a scenario like i need to run a SQL select query to export data to CSV file using BCP utility,to achieve this i have created a batch file and running this batch file from command prompt. Its running perfectly when i pass the SQL query with less lines of code like 50,60 as parameter to batch file but when i try to pass the SQL query with more than 300 line of code its throwing error like The input line is too long and Syntax of command is incorrect,can anyone help me to resolve this issue?

Thanks, Raghu

Upvotes: 0

Views: 734

Answers (1)

jamie
jamie

Reputation: 775

try calling one of the sql command line execution tools. isql, osql, sqlcmd. These, if I rceall correctly, will allow you to pass a file in as a parameter with the query. you can bypass the DOS cmdshell limitation of parameter size. Seems like that is most certainly what is happening. Just create a DOS batch file to execute isql/osql or sqlcmd (isql/osql are just older verions. SQLCMD is newest. Not sure which version of SQL Server you are on.

Upvotes: 1

Related Questions