开发者

I want to import data from my stored procedure to a csv file

I am using SQL Server 2005. I want to create a stored procedure that will save data into a .csv file.

Below is the query I am trying but it is not creating any file in my system:

use PBMS_DocumationWorkflow
go
create proc s_bcpMasterSysobjects
as
   select   '"' + name + '"'
           开发者_C百科 + ',' + '"' + convert(varchar(8), crdate, 112) + '"'
            + ',' + '"' + convert(varchar(8), crdate, 108) + '"'
   from master..sysobjects
   order by crdate desc
go
declare @sql varchar(8000)
select @sql = 'bcp "exec PBMS_DocumationWorkflow..s_bcpMasterSysobjects"
                out c:\bcp\sysobjects.txt -c -t, -T -S'+ @@servername
exec master..xp_cmdshell @sql

Please suggest the cause or give me sample code which works fine.

Thanks.


Try changing the "out" to "queryout"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜