SQL SERVER使用ODBC 驱动建立的链接服务器调用存储过程时参数不能为NULL值

原文: SQL SERVER使用ODBC 驱动建立的链接服务器调用存储过程时参数不能为NULL值

    我们知道SQL SERVER建立链接服务器(Linked Server)可以选择的驱动程序非常多,最近发现使用ODBC 的 Microsoft OLE DB 驱动程序建立的链接服务器(Linked Server), 调用存储过程过程时,参数不能为NULL值。

clipboard

否则就会报下面错误提示:

对应的英文错误提示为:

EXEC xxx.xxx.dbo.Usp_Test NULL,NULL,'ALL'

Msg 7213, Level 16, State 1, Line 1

The attempt by the provider to pass remote stored procedure parameters to remote server 'xxx'  failed. Verify that the number of parameters, the order, and the values passed are correct.

对应的中文错误提示为:

EXEC xxx.xxx.dbo.Usp_Test NULL,NULL,'ALL'

Msg 7213, Level 16, State 1, Line 1

提供程序将远程存储过程参数传递给远程服务器 'xxx' 的尝试失败。请确保参数的数目、顺序和所传递的值正确。

 

EXEC xxx.xxx.dbo.Usp_Test '','','ALL' 或者给参数赋予一个合适的值则不会报任何错误。另外使用Microsoft OLE DB Provider for SQL Server驱动方式建立的链接服务器(Linked Server)调用存储过程时参数就可以为NULL。

猜你喜欢

转载自www.cnblogs.com/lonelyxmas/p/9428261.html