SQL Server xp

编程入门 行业动态 更新时间:2024-10-25 04:26:42
SQL Server xp_cmdshell无法导出数据(SQL Server xp_cmdshell fail to export data)

我想从名为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; GO

However 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

更多推荐

本文发布于:2023-07-15 21:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1119344.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQL   Server   xp

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!