Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQLCMD in batch file

262 views
Skip to first unread message

Richard Mogy

unread,
May 12, 2015, 7:59:14 PM5/12/15
to
I have created an sqlcmd batch file. When I execute the batch file, I get the 1> notation and the statements won't execute until a type exit.

However, if I put the statements into an ascii file and put sqlcmd -i statemetfile.txt in the batch file, it runs perfectly.

My statements in the sqlcmd batchfile are:

sqlcmd -q "truncate table ....."
sqlcmd -Q "insert into tablename select * from x"

What am I doing wrong?

Erland Sommarskog

unread,
May 13, 2015, 3:16:20 AM5/13/15
to
Stay away from -q option, but stick to -Q. -q Runs an initial batch and
keeps you connected. -Q runs the query and exits.



--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
0 new messages