使用SSMS 2008客户端工具逆向生成了创建链接服务器的脚本时,在测试环境执行是报如下错误:'(null)' is an invalid product name.
USE [master]
GO
IF EXISTS (SELECT srv.NAME
FROM sys.servers srv
WHERE srv.server_id != 0
AND srv.NAME = N'MES_DB_LINK_TEST')
EXEC master.dbo.Sp_dropserver
@server=N'MES_DB_LINK_TEST',
@droplogins='droplogins'
go
EXEC master.dbo.Sp_addlinkedserver
@server = N'MES_DB_LINK_TEST',
@provider=N'SQLNCLI',
@datasrc=N'192.168.xxx.xxx',
@catalog=N'TEST'
EXEC master.dbo.Sp_addlinkedsrvlogin
@rmtsrvname=N'MES_DB_LINK_TEST',
@useself=N'False',
@locallogin=NULL,
@rmtuser=N'tuser',
@rmtpassword='123456'
go
消息 15429,级别 16,状态 1,过程 sp_addlinkedserver,第 45 行
'(null)' is an invalid product name.
出现如上错误,是因为这个是SQL Server Management Studio 的一个bug来的。它逆向生成脚本时,生成的脚本少了一些参数,所以你执行脚本时就会报上述错误。这个bug已经在SQL Server Management Studio 2012解决了,你用SSMS 2012逆向生成脚本就会发现会多一个参数@srvproduct
USE [master]
go
IF EXISTS (SELECT srv.NAME
FROM sys.servers srv
WHERE srv.server_id != 0
AND srv.NAME = N'MES_DB_LINK_TEST')
EXEC master.dbo.Sp_dropserver
@server=N'MES_DB_LINK_TEST',
@droplogins='droplogins'
go
EXEC master.dbo.Sp_addlinkedserver
@server = N'MES_DB_LINK_TEST',
@srvproduct=N'',
@provider=N'SQLNCLI',
@datasrc=N'192.168.xxx.xxx',
@catalog=N'TEST'
EXEC master.dbo.Sp_addlinkedsrvlogin
@rmtsrvname=N'MES_DB_LINK_TEST',
@useself=N'False',
@locallogin=NULL,
@rmtuser=N'tuser',
@rmtpassword='123456'
go