无法在SSMS上创建存储过程

问题描述 投票:0回答:1

我正在尝试在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'

任何帮助将不胜感激。

sql sql-server database stored-procedures ssms
1个回答
0
投票

尝试以下操作:

exec master..xp_cmdshell 'bcp "[IMBookingApp].[dbo].[userTEST]" out "c:\S3\users.csv" -c -t, -T'
© www.soinside.com 2019 - 2024. All rights reserved.