Bug #: 50001012 (SQL Hotfix)

Symptoms

In Microsoft SQL Server 2005 Service Pack 2 (SP2), the following tasks in a maintenance plan may lose database context in certain circumstances:

  • Check Database Integrity

  • Execute T-SQL Statement

For example, if a Check Database Integrity task is configured to check integrity on multiple databases, the task repeatedly checks the default database.

For the Execute T-SQL Statement task, this problem occurs if the following conditions are true:

  • The Execute T-SQL Statement task contains multiple batches.

  • The batches are separated by the GO statement.

  • No batches use the USE statement to specify the database.

  • The statements in each batch do not contain the database name.

In this scenario, those statements in the second batch and in succeeding batches will be executed against the default database.

Note You can confirm that this problem has occurred by using SQL Server Profiler. When you trace the maintenance plan execution, see the Database column in SQL Server Profiler.

Resolution

This problem occurs in SQL Server 2005 builds 3042 through 3053 and in SQL Server 2005 builds 3150 through 3158. If you are running a build of SQL Server 2005 SP2 between 3042 and 3053, download and install the following critical update from the Microsoft Download Center.

To get the stand-alone package for this update, go to the Microsoft Update Catalog website.

After you install this critical update, the build of SQL Server 2005 is 3054.

For more information about how to download Microsoft support files, click the following article number to view the article in the Microsoft Knowledge Base:

119591 How to obtain Microsoft support files from online services Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.

File information

The English version of this critical update has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in Coordinated Universal Time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time item in Control Panel.

SQL Server 2005, 32-bit version

File name

File version

File size

Date

Time

Platform

Microsoft.sqlserver.maintenanceplantasks.dll

9.0.3054.0

296,304

23-Mar-2007

21:13

x86

Sqlaccess.dll

2005.90.3054.0

350,576

23-Mar-2007

21:13

x86

Sqlservr.exe

2005.90.3054.0

29,181,808

23-Mar-2007

21:13

x86

SQL Server 2005, x64-based version

File name

File version

File size

Date

Time

Platform

Microsoft.sqlserver.maintenanceplantasks.dll

9.0.3054.0

296,304

23-Mar-2007

21:13

x86

Sqlaccess.dll

2005.90.3054.0

357,744

24-Mar-2007

02:40

x86

Sqlservr.exe

2005.90.3054.0

38,516,080

24-Mar-2007

02:40

x64

SQL Server 2005, Itanium-based version

File name

File version

File size

Date

Time

Platform

Microsoft.sqlserver.maintenanceplantasks.dll

9.0.3054.0

296,304

23-Mar-2007

21:13

x86

Sqlaccess.dll

2005.90.3054.0

352,112

24-Mar-2007

03:59

x86

Sqlservr.exe

2005.90.3054.0

72,583,024

24-Mar-2007

03:59

ia64

If you are running any build of SQL Server 2005 SP2 between 3150 and 3158, click the following article number to view the article in the Microsoft Knowledge Base:

934459 FIX: The Check Database Integrity task and the Execute T-SQL Statement task in a maintenance plan may lose database context in certain circumstances in SQL Server 2005 builds 3150 through 3158
  To obtain this critical update in an automated way, visit the following Microsoft Update Web site:

http://update.microsoft.com After you install this critical update, the build of SQL Server 2005 is 3161.

For more information about how to determine the SQL Server version and edition, click the following article number to view the article in the Microsoft Knowledge Base:

321185 How to identify your SQL Server version and edition
 

Status

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

More Information

In the original release version of SQL Server 2005 SP2 and earlier versions, commands that are related to maintenance plan tasks are accumulated and then executed at the same time. When an error occurs, tasks are no longer executed, and the remaining maintenance tasks are not performed. In SQL Server 2005 SP2, individual batches are submitted one at a time. In the original release version of SQL Server 2005 SP2, the database connection was reset between batches. Later batches were left in the context of the default database instead of in the context that was present before the GO statement was executed. The tasks that were affected depended on the context that was present before the GO statement was executed, specifically the Check Database Integrity task and the Execute T-SQL Statement task.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

What affected your experience?

Thank you for your feedback!

×