尝试将自定义查询导出到csv文件我编写了以下命令:
sqlcmd [-S myserver -d mydb -E -Q "SELECT column1 ,column_date, DATENAME(WEEKDAY, column_date) AS day_of_week ,distinc_events_count ,total_events_count ,event_duration FROM dbo.event_daily_stats ORDER BY column1" -o "D:\MyData.csv" -h-1 -s"," -w 700]
但它返回了以下错误消息:
The identifier that starts with '-S myserver -d mydb -E -Q "SELECT column1 ,column_date, DATENAME(WEEKDAY, column_date) AS day_of_week ,distinc_events_count ,' is too long. Maximum length is 128.
有谁知道如何解决这个问题?
谢谢!
答案 0 :(得分:2)
我执行了没有“[”和“]”的命令,没有问题,你试过这种方式吗?
sqlcmd -S myserver -d mydb -E -Q "SELECT column1 ,column_date, DATENAME(WEEKDAY, column_date) AS day_of_week ,distinc_events_count ,total_events_count ,event_duration FROM dbo.event_daily_stats ORDER BY column1" -o "D:\MyData.csv" -h-1 -s"," -w 700
答案 1 :(得分:1)
我认为问题是你应该在SSMS中运行它,而不应该在命令提示符下运行它。