Possible Duplicate:
How to export data as CSV format from SQL Server using sqlcmd?可能重复:如何使用sqlcmd从SQL Server导出数据为CSV格式?
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:
我正在尝试创建一个.bat文件,使用sqlcmd从数据库进行查询。这是我到目前为止使用的在线资源:
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.
如果我在当前状态下运行它,则不会创建CSV文件。
1 个解决方案
#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.
批处理文件没有空闲的空格,因此您不能只在所需的位置插入换行符。将所有代码放在一行中。
#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.
批处理文件没有空闲的空格,因此您不能只在所需的位置插入换行符。将所有代码放在一行中。