1

Trying to export custom query to csv file I wrote the following command:

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]

but it returned the following error message:

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.

Does anyone know how this issue could be solved?

Thank you!

0

2 Answers 2

2

I executed the command without "[" and "]" with no problem, have you tried in this way?

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
Sign up to request clarification or add additional context in comments.

1 Comment

I pasted the command changing only the query, myserver and mydb values and i did not receive any error. Maybe you accidentally deleted the "-" before "S". Can you paste the command you used?
1

I think the problem is that you're trying to run this inside of SSMS when it should be run at a command prompt instead.

Comments

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.