Syntax error with :OUT and C:/ - SQL Query to CSV File

Copper Contributor

Hi all, 

 

I'm trying to export an SQL query for several tables into individual CSV files. 

 

Im getting an error with the syntax with the colon in front of "OUT" and the backslash for the where I want to save the file to C:\....

_________

:OUT c:\XXXXXXX.csv
SELECT * FROM [XXXXXXX].[XXXXXX].XXXXX
GO

________

 

Is anyone able to tell me what I did wrong? 

1 Reply

Looks like you try to run the query in a SSMS query window, right?

To run a SqlCmd script in SSMS you have to switch into SqlCmd mode first.

 

Menue "Query" => "SQLCMD-Mode"