查询到text / csv文件的结果集 [英] Result set of a query into a text / csv file
问题描述
大家好,
我想要查询或存储过程来将查询的结果集检索到数据文件中。
I尝试使用bcp,如下所述抛出错误:
Hi All,
I want a query or stored proc to retrieve the result set of a query into a Datafile.
I have tried using bcp which throws error as mentioned below:
EXEC master..xp_cmdshell 'bcp "select
USERID_FK FROM ADM_USERROLES" queryout "D:\bcptest.txt" -T -c -t,'
对于上述查询我收到错误
对象'xp_cmdshell',数据库'mssqlsystemresource',架构'sys'上的EXECUTE权限被拒绝。
请建议我该怎么办...
谢谢&此致,
Mathi。
for the above query I'm getting the error as
The EXECUTE permission was denied on the object 'xp_cmdshell', database 'mssqlsystemresource', schema 'sys'.
Please suggest what can I do...
Thanks & Regards,
Mathi.
推荐答案
由于恶意用户有时会尝试使用xp_cmdshell提升其权限,因此默认情况下会禁用 xp_cmdshell 。使用sp_configure或Policy Based Management启用它。有关更多信息,请参阅xp_cmdshell服务器配置选项。
Because malicious users sometimes attempt to elevate their privileges by using xp_cmdshell, xp_cmdshell is disabled by default. Use sp_configure or Policy Based Management to enable it. For more information, see xp_cmdshell Server Configuration Option.
xp_cmdshell(Transact-SQL) [ ^ ]
SQL SERVER - 使用sp_configure启用xp_cmdshell [ ^ ]
这篇关于查询到text / csv文件的结果集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!