我想将名为dbo.DimServere的表中的列(TcpIpAddress)中的值导出到纯文本(位于服务器中)。我具有系统管理员权限。
-- 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
但是,当我运行此脚本时,我收到以下消息,并且没有创建任何文件:
我哪里做错了?
1条答案
按热度按时间cbeh67ev1#
该bcp语句中的路径将相对于服务器,因为您是在服务器上执行它的。
服务器上是否存在该路径?
此外,尝试将路径更改为更容易访问的路径,如c:\output ...,然后您可以尝试该文件夹上的权限,以确保不是操作系统权限导致语句失败。
希望能有所帮助