FIX: Error 7359 when you run a query against a user-defined function or a view that uses a synonym on a linked server in SQL Server 2005, SQL Server 2008 or SQL Server 2008 R2

Article translations Article translations
Article ID: 2498818 - View products that this article applies to.
Microsoft distributes Microsoft SQL Server 2005, Microsoft SQL Server 2008 and Microsoft SQL Server 2008 R2 fixes as one downloadable file. Because the fixes are cumulative, each new release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005, Microsoft SQL Server 2008 and SQL Server 2008 R2 fix release.

The fix that is described in this article is available for the following versions of SQL Server:
  • Microsoft SQL Server 2005 Service Pack 3 (SP3)
  • Microsoft SQL Server 2005 Service Pack 4 (SP4)
  • Microsoft SQL Server 2008 Service Pack 1 (SP1)
  • Microsoft SQL Server 2008 Service Pack 2 (SP2)
Expand all | Collapse all

On This Page

SYMPTOMS

Consider the following scenario:
  • You create a linked server on a computer that is running Microsoft SQL Server 2005, Microsoft SQL Server 2008 or Microsoft SQL Server 2008 R2. The linked server points to an OLE DB data source on a remote server.
  • You create a synonym for a table on the linked server.
  • You create a user-defined function that uses the synonym, or you create a view that uses the synonym. Then, you run a query against the user-defined function or the view.

    Note When you run the query, an execution plan is cached.
  • You perform an operation on a remote server to update the schema version of the table on the linked server. For example, you rebuild the index of the table on the remote server to update the schema version of the table on the linked server.
  • You run another query against the user-defined function or the view.
In this scenario, you receive an error message that resembles the following:
Server: Msg 7359, Level Level Number, State State Number, Line Line Number
The OLE DB provider "Provider Name" for linked server "Linked Server Name" reported a change in schema version between compile time ("Compile Time") and run time ("Run Time") for table "Linked Table Name".
Note Provider Name is a placeholder that represents the name of the OLE DB provider. Linked Table Name is a placeholder that represents the name of the table that is on the linked server.

CAUSE

This issue occurs because the existing execution plan is not cleared correctly. This causes the schema version to change, because the user-defined function or the view is recompiled when the second query is run. Therefore, the error occurs.

RESOLUTION

Cumulative update information

SQL Server 2008 R2 Service Pack 1

The fix for this issue was first released in Cumulative Update 1 for SQL Server 2008 R2 Service Pack 1. For more information about how to obtain this cumulative update package, click the following article number to view the article in the Microsoft Knowledge Base:
2544793 Cumulative Update package 1 for SQL Server 2008 R2 Service Pack 1
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2567616 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 Service Pack 1 was released

SQL Server 2008 R2

The fix for this issue was first released in Cumulative Update 7. For more information about how to obtain this cumulative update package for SQL Server 2008 R2, click the following article number to view the article in the Microsoft Knowledge Base:
2507770 Cumulative Update package 7 for SQL Server 2008 R2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 R2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
981356 The SQL Server 2008 R2 builds that were released after SQL Server 2008 R2 was released

For SQL Server 2005 SP3

The fix for this issue was first released in Cumulative Update 15. For more information about how to obtain this cumulative update package for SQL Server 2005 SP3, click the following article number to view the article in the Microsoft Knowledge Base:
2507766 Cumulative update package 15 for SQL Server 2005 SP3
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 SP3 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
960598 The SQL Server 2005 builds that were released after SQL Server 2005 SP3 was released

For SQL Server 2005 SP4

The fix for this issue was first released in Cumulative Update 3. For more information about how to obtain this cumulative update package for SQL Server 2005 SP4, click the following article number to view the article in the Microsoft Knowledge Base:
2507769 Cumulative update package 3 for SQL Server 2005 SP4
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2005 SP4 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
937137 The SQL Server 2005 builds that were released after SQL Server 2005 SP4 was released

For SQL Server 2008 SP1

The fix for this issue was first released in Cumulative Update 13. For more information about how to obtain this cumulative update package for SQL Server 2008 SP1, click the following article number to view the article in the Microsoft Knowledge Base:
2497673 Cumulative update package 13 for SQL Server 2008 SP1
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 SP1 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
970365 The SQL Server 2008 builds that were released after SQL Server 2008 SP1 was released

For SQL Server 2008 SP2

The fix for this issue was first released in Cumulative Update 3. For more information about how to obtain this cumulative update package for SQL Server 2008 SP2, click the following article number to view the article in the Microsoft Knowledge Base:
2498535 Cumulative update package 3 for SQL Server 2008 SP2
Note Because the builds are cumulative, each new fix release contains all the hotfixes and all the security fixes that were included with the previous SQL Server 2008 SP2 fix release. We recommend that you consider applying the most recent fix release that contains this hotfix. For more information, click the following article number to view the article in the Microsoft Knowledge Base:
2402659 The SQL Server 2008 builds that were released after SQL Server 2008 SP2 was released

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

MORE INFORMATION

For more information about how to use Transact-SQL to create a synonym, visit the following Microsoft Developer Network (MSDN) website:
How to use Transact-SQL to create a synonym

Properties

Article ID: 2498818 - Last Review: July 18, 2011 - Revision: 4.0
APPLIES TO
  • Microsoft SQL Server 2008 Developer
  • Microsoft SQL Server 2008 Enterprise
  • Microsoft SQL Server 2008 Standard
  • Microsoft SQL Server 2008 Web
  • Microsoft SQL Server 2008 Workgroup
  • Microsoft SQL Server 2008 Service Pack 1
  • Microsoft SQL Server 2008 Service Pack 2
  • Microsoft SQL Server 2005 Enterprise Edition
  • Microsoft SQL Server 2005 Developer Edition
  • Microsoft SQL Server 2005 Standard Edition
  • Microsoft SQL Server 2005 Workgroup Edition
  • Microsoft SQL Server 2005 Service Pack 3
  • Microsoft SQL Server 2005 Service Pack 4
Keywords: 
kbqfe kbfix kbexpertiseadvanced kbsurveynew KB2498818

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com