我想将列(TcpIpAddress)中的值从名为dbo.DimServere的表导出为纯文本(位于服务器中)。我有sysadmin权限。
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1; -- 1 for at enable
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
-- Extracting information from the databse
EXEC xp_cmdshell 'bcp "SELECT TcpIpAddress FROM [SIT-DVH].[dbo].[DimServere]" queryout "C:\Users\b013904\Desktop\Output\bcptest.txt" -T -c -t,'
-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1;
GO
-- To update the currently configured value for advanced options.
RECONFIGURE;
GO
-- To disable the feature.
EXEC sp_configure 'xp_cmdshell', 0; -- 0 for at disable
GO
-- To update the currently configured value for this feature.
RECONFIGURE;
GO
然而,当我运行此脚本时,我得到以下消息并且没有创建文件:
我做错了什么?
先谢谢
丹尼尔
答案 0 :(得分:0)
该bcp语句中的路径将相对于服务器,因为您在服务器上执行它。
服务器上是否存在该路径?
另外,尝试将路径更改为更容易访问的内容,如c:\ output。 ..然后你可以使用该文件夹的权限,以确保不是导致语句失败的操作系统权限。
希望有所帮助