Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has o

今天执行bcp命令,将查询结果生成一个excel文件放在本地。

命令:

EXEC master..xp_cmdshell N'bcp "SELECT ''数据库ID'',''数据库名称'',''对象Id'',''表名'',''查询语句'',''总消耗CPU 时间(ms)'',''执行次数'',''平均消耗CPU 时间(ms)'',''最后一次执行时间'',''最小执行时间(ms)]'',''最大执行时间(ms)''  UNION ALL SELECT CAST(dbid AS NVARCHAR(100)),dbname,CAST(ObjectId AS NVARCHAR(100)) ,ObjectName ,SelectStatement ,CAST(total_worker_time AS NVARCHAR(100)) , CAST(execution_count AS NVARCHAR(100)) ,CAST( avg_elasped_time AS NVARCHAR(100)) ,CAST( last_execution_time AS NVARCHAR(100)),CAST(min_worker_time AS NVARCHAR(100)) ,CAST( max_worker_time AS NVARCHAR(100))  FROM dba.dbo.bdd_temp_find_top_select_cpu" queryout e:top_select_cpu.txt -c  -S"10.0.8.102"  -T' 

报错:

Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has o_第1张图片

出错原因:

-S这里的server name输入错误。公司生成环境服务器名称是10.0.8.102\sqlinstance,我却写成了10.0.8.102

解决办法:

将server name改成正确的server name即可。

你可能感兴趣的:(Error = [Microsoft][SQL Server Native Client 11.0]A network-related or instance-specific error has o)