我想从名为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但是,当我运行这个脚本我得到以下消息,并没有创建文件:
我究竟做错了什么?
先谢谢了
丹尼尔
I want to export values from a column (TcpIpAddress) from a table called dbo.DimServere to a plain text (located in the server). I have sysadmin rights.
-- 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; GOHowever when i run this script i get the following mesage and no file is been created:
What am i doing wrong?
Thanks in advanced
Daniel
最满意答案
由于您在服务器上执行它,因此该bcp语句中的路径将与服务器相关。
该路径是否存在于服务器上?
此外,尝试将路径更改为更容易访问的内容,如c:\ output。 ..然后你可以使用该文件夹的权限,以确保不是导致语句失败的操作系统权限。
希望有所帮助
The path in that bcp statement will be relative to the server since you're executing it on the server.
Does that path exist on the server?
Also, try changing the path to something more accessible like c:\output. .. then you can play around with the permissions on that folder to ensure that is not a os permission that's causing the statement to fail.
Hope that helps
更多推荐
发布评论