我已经在SQL Server 2005中创建了一个存储过程,用于将查询结果导出到网络路径。该用户是SQL用户,并且也已在AD中创建。我登录的服务器是远程服务器,具有sysadmin特权。执行该存储过程或查询时,我遇到了以下错误:
output
SQLState = 08001, NativeError = 53
Error = [Microsoft][SQL Native Client]Named Pipes Provider: Could not open a connection to SQL Server [53].
SQLState = 08001, NativeError = 53
Error = [Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Native Client]Login timeout expired
NULL
在我登录服务器并执行查询时,似乎我无法访问远程服务器。该过程还会在凌晨01:30自动执行。所执行的命令是bcp命令:
DECLARE @SQLCommand [varchar](max)
,@Query [varchar](max)
,@SERVER VARCHAR(1000)
SET @Query = 'SELECT * FROM INFINITY_SYSTEM.[dbo].[CTI_WFM_LILO_View]'
SET @SERVER = '[server_name]'
SET @SQLCommand = 'EXEC xp_cmdshell ''bcp "' + @Query + '" queryout "\\network_path\lilo'+CONVERT(VARCHAR,GETDATE(),112)+'.csv" -Uusername -Ppassword -c -t, -r, -S"'+@SERVER+'"''' --also tried with -T in stand of the -Uusername -Ppassword
EXEC (@SQLCommand)
当我尝试将该命令从本地sqlserver的本地数据库复制到相同路径时,它可以正常工作。
谢谢。