1
Answer

BCP utility on SQL managed instance.

Sumit Rajguru

Sumit Rajguru

6y
1.6k
1
Hi all,
 
I have a function which returns a table.
 
I am exporting this table to an Excel file using the BCP utility. I want to use this functionality on SQL Managed instance.
 
Declare @Command varchar(2000)
set @Command = 'bcp "select * from ' + @DatabaseName + '.dbo.TableName order by ColumnX" queryout
"D:\Test\' + @DatabaseName +'_TableData.xls" -c -t" " -r"\n" -S Servername -T -S'
EXEC master.dbo.xp_cmdshell @Command
 
kindly suggest me the proper way to achieve this task.
 
All suggestions are appreciated.
Thanks in advance.
Answers (1)