1

This is my command line:

sqlcmd -S DEVSERVER\SQLEXPRESS -i  c:\SQL_Query.sql -o c:\CSV_Output.csv -s”,”

And my sql script:

SELECT * FROM dbo.pay

The file with this error message:

Msg 208, Level 16, State 1, Server DEVSERVER\SQLEXPRESS, Line 1
Invalid object name 'dbo.pay'.

1 Answer 1

3

Specify database name.

sqlcmd -S [sql server name] –d [database name] –U [user name] –P [password] –Q "your sql query" –s "," –o "D:\demo.csv"

Sign up to request clarification or add additional context in comments.

6 Comments

sqlcmd -S DEVSERVER\SQLEXPRESS –d AWP_WWW –U dbadmin –P Admin123$ –Q ”SELECT * FROM dbo.pay –s “,” –o “C:\export-sql-server-to-csv\output.txt”
this is my command line, when i execute it it shows "Unexpected Arguement" in cmd. Need help thx.
Can you try with file name output.CSV?
It is because of double quotes(copy & paste). Can you type the double quotes manually and try?
Thanks Imran, i typed the double quotes manually and i able to fixed the problem. But when i add " WHERE st_code='abc' , 'abc1' ; " statement, it appears the same problem again.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.