SQL Server Q&A

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘Dr. Watson’

FIX: Unhandled exception during upgrade when excluding database with 30-character name

Symptoms
When running the Version Upgrade Wizard to upgrade SQL Server 6.x to SQL Server 7.0, if a database whose name is 30 characters long is excluded from the upgrade, the wizard generates an unhandled exception and stops running.
If Dr. Watson is set as the default debugger, an error message similar to the following will be displayed immediately after clicking the EXCLUDE button:

An application error has occurred
and an application error log is being generated.
upgrade.exe
Exception: privileged instruction (0xc0000065), Address: 0×007f1a80
Resolution
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article. This problem was first corrected in SQL Server 7.0 Service Pack 1. For more information, contact your primary support provider.

FIX: SEM: Appended Backup Database with Verify Always Checks Only FILE Number = 1

Symptoms
When you use SQL Server Enterprise Manager to backup and verify the backup of a database, the verification assessment of the backup is not reliable if the backup set is appended to either a previously existing file or device.
Furthermore, if you attempt to establish a Database Maintenance Plan through the Database Maintenance Wizard and you select Verify the Backup to a tape that contains a Microsoft Windows NT file backup that is File number 1, you will see this error message:

[Microsoft SQL-DMO (ODBC SQLState: 42000)]
Error 3143: [Microsoft][ODBC SQL Server Driver][SQL Server]
The data set on device ‘\\.\Tape0′ is not a SQL Server backup set.
[Microsoft][ODBC SQL Server Driver][SQL Server]Backup or restore
operation terminating.Also, if you put a SQL Server database backup on the tape first and you then attempt to perform a Windows NT backup, a Dr. Watson error (0xc000005) occurs.
Resolution
Here are a few ways to work around this problem:Run this line of code from Query Analyzer to the backup device or file to identify the last backup set in the file:

RESTORE HEADERONLY Next, run this code:

RESTORE VERIFYONLY FROMDISK = N’c:\BACKUP\pubsbk.jnk’ WITHFILE = X ,NOUNLOAD where X is the maximum file id identified by the Position output column from RESTORE HEADERONLY. If you use the Database Maintenance Wizard, alter the previous RESTORE statement in the Schedule Task.
-or-
Consider selecting the Overwrite Existing Media option to make sure that the backed up file is always the first backup set in the file.
-or-
Consider backing up the SQL Server databases to a tape on which only SQL Server database backups exist.
-or-
Consider scripting the commands and then run the commands from a command prompt or batch file.For example:

DECLARE @DBNameVARCHAR(200),@TargetLocation VARCHAR(1000),@BackupNameVARCHAR(200),@FileNumberVARCHAR(10),@xpcmdStringVARCHAR(2000),@PrintStringVARCHAR(200)SELECT @DBName= ‘[pubs]‘,@TargetLocation = ‘c:\BACKUP\pubsbk.jnk’ ,@BackupName= ‘pubs backup’SELECT @xpcmdString = ‘BACKUP DATABASE ‘+@DBName+’ TO DISK = N’ + CHAR(39)+@TargetLocation+CHAR(39)+’ WITHNOINIT ,NOUNLOAD ,NAME = N’ + CHAR(39)+@BackupName+CHAR(39)+’,NOSKIP ,STATS = 10,NOFORMAT ‘EXEC (@xpcmdString)CREATE TABLE #TempBackupResults(BackupName nvarchar(128),BackupDescriptionnvarchar(255),BackupType smallint,ExpirationDate datetime,Compressed tinyint,Position smallint,DeviceType tinyint,UserName nvarchar(128),ServerName nvarchar(128),DatabaseName nvarchar(128),DatabaseVersionint,DatabaseCreationDatedatetime,BackupSize numeric(20,0),FirstLSN numeric(25,0),LastLSN numeric(25,0),CheckpointLSNnumeric(25,0),DatabaseBackupLSNnumeric(25,0),BackupStartDatedatetime,BackupFinishDatedatetime,SortOrder smallint, CodePage smallint,UnicodeLocaleId int,UnicodeComparisonStyle int,CompatibilityLeveltinyint,SoftwareVendorIdint,SoftwareVersionMajorint,SoftwareVersionMinorint,SoftwareVersionBuildint,MachineName nvarchar(128))SELECT @xpcmdString = ‘RESTORE HEADERONLY FROM DISK = N’ + CHAR(39)+@TargetLocation+CHAR(39)INSERT#TempBackupResults EXEC (@xpcmdString)SELECT @FileNumber = CONVERT(VARCHAR(20), MAX(Position))FROM #TempBackupResults WHERE BackupName=@BackupNameSELECT @xpcmdString = ‘RESTORE VERIFYONLY FROM DISK = N’ + CHAR(39)+@TargetLocation+CHAR(39)+’ WITHFILE = ‘ + @FileNumberSELECT @PrintString = ‘Verifying Integrity of Backup Set Number ‘ + @FileNumberPRINT @PrintStringEXEC (@xpcmdString)DROP TABLE #TempBackupResults

FIX: DTSTransferObjects with Events Generates an Error Message and an Access Violation in Visual Basic

Symptoms
This article describes one possible reason why a Data Transformation Services (DTS) package created in Microsoft Visual Basic code may fail with an error message and an access violation (AV).
When you create a DTSTransferObjectsTask task in a DTS package and specify the WITHEVENTS keyword, and you then run the DTS package from Microsoft Visual Basic code, the package may fail with the following error message:

ErrorCode: -2147221499
Source: Microsoft Data Transformation Services (DTS) Package
Description: Need to run the object to perform this operation After you set a breakpoint at the beginning of the OnProgress procedure, and you single step through your OnProgress code in Visual Basic, you will see the underlying access violation (AV):

Package failed error: x80040005, x80040000 + 5
Provider generated code execution exception: EXCEPTION_ACCESS_VIOLATION Then, Dr. Watson shows an error message similar to the following:

The instruction at “0×0fa9183f” referenced memory at “0×00000001″. The memory could not be “read”. When you run the Visual Basic application under the debugger WinDbg you will see a first chance exception of type access violation in OLEAUT32!SysAllocStringByteLen.
NOTE: This article is specifically about the OnProgress event of a DTSTransferObjectsTask!
The most common causes for the error message and access violation when you use DTS in Visual Basic applications are described in the following Microsoft Knowledge Base article:
271889?(http://support.microsoft.com/kb/271889/EN-US/) PRB: Error Message: “Exception Access Violation 2147221499.Need to run the object to perform this operation” Occurs When You Run a DTS Package in Microsoft Visual Basic Code
Resolution
To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/EN-US/) INF: How To Obtain the Latest SQL Server 2000 Service PackNOTE: The following hotfix was created before the release of Microsoft SQL Server 2000 Service Pack 3.
The English version of this fix should have the following file attributes or later:

DateTimeVersionSizeFile name————————————————————–06-Jan-200220:238.00.5661,901,120 bytesDtspkg.dll NOTE: Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.