0

Possible Duplicate:
How to export data as CSV format from SQL Server using sqlcmd?

I'm trying to create a .bat file to query from a database using sqlcmd. This is what I got so far using sources online:

sqlcmd -S servername\sqlexpress -d DNAME -U username -P password
-Q "SELECT 1,2,3,4,5
    FROM table1
    SELECT 6,7,8,9,10
    FROM table2
    BACKUP DATABASE [DNAME] TO DISK = 'C:\test.csv'"

If I run this at its current state the CSV file isn't being created.

0

1 Answer 1

0

Batch files do not have free whitespace, so you cannot just insert line breaks where you want. Put all the code in a single line instead.

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

1 Comment

I have removed the spaces however it still does not create a csv file. I'm very new to batch files and sqlcmd's as I just started but I appricate the help I have recieved

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.