我正在尝试在SSMS中创建存储过程,以将查询结果导出到CSV。但是我在创建时遇到了错误。
SQL命令
CREATE PROCEDURE SelectUsers
AS
SELECT * from [IMBookingApp].[dbo].[usertest]
INTO OUTFILE 'C:/S3/users.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';
GO;
错误
Msg 156, Level 15, State 1, Procedure SelectUsers, Line 4 [Batch Start Line 0]
Incorrect syntax near the keyword 'INTO'
任何帮助将不胜感激。
尝试以下操作:
exec master..xp_cmdshell 'bcp "[IMBookingApp].[dbo].[userTEST]" out "c:\S3\users.csv" -c -t, -T'