I am trying to create a stored procedure in SSMS to export the query result to CSV. But I am getting below error while creating.
SQL statement:
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;
Error
Msg 156, Level 15, State 1, Procedure SelectUsers, Line 4 [Batch Start Line 0]
Incorrect syntax near the keyword 'INTO'
Any help would be appreciated.