Hi
I have an issue, I could not export data by using bcp command. I am using below code, but csv file cannot be created
Below is my code
declare @sql varchar(8000)
DECLARE @columnHeader VARCHAR(8000)
DECLARE @table_name VARCHAR(50) ='ZR_tbl_Export_FILE'
DECLARE @Servername varchar(100)='sils-pc\SQLEXPRESS'
SELECT @columnHeader = COALESCE(@columnHeader+',' ,'')+ ''''+column_name +'''' FROM
guard_security.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=@table_name
SELECT @sql = 'bcp "SELECT '+ @columnHeader +' UNION ALL SELECT * FROM ZR_tbl_Export_FILE" queryout
c:\ExportExcel\Export_FILE.csv -c -t, -T -S'+ @servername
exec master..xp_cmdshell @sql
pls advice me
Thank you
Maideen