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 ‘sql server 7’

FIX: Reading Perflib Registry Values Terminates SQL Server Startup with Fatal Exception

Symptoms
During SQL Server startup, a “fatal exception” may occur when SQL Server reads the following Perflib registry values:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib\009\COUNTERThe SQL Server 7.0 SP1 Errorlog shows the following stack dump during startup:

Short Stack Dump0×004fe58d Module(sqlservr+fe58d) (RegGetCntrList+1be)0×004fe278 Module(sqlservr+fe278) (LoadObjects+38)0×004fe18e Module(sqlservr+fe18e) (pm_InitializeSharedMemory+1a7)0×004fcc8a Module(sqlservr+fcc8a) (sqlservr_main+40c)0×77dd8c10 Module(ADVAPI32+18c10) (RegisterServiceCtrlHandlerA+532)2000-06-22 16:52:07.54 serverCImageHelper::GetSym Error – The specified module could not be found.
Resolution
To resolve this problem, obtain the latest service pack for SQL Server 2000. For additional information, click the following article number to view the article in theMicrosoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/EN-US/) INF: How to Obtain the Latest SQL Server 2000 Service Pack

FIX: Query with SET NO_BROWSETABLE Option Set ON May Generate Access Violation

Symptoms
When you execute an INSERT, DELETE or UPDATE query that operates on objects with underlying triggers, the query may terminate with the following error message and an Access Violation occurs:

ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 52 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.The Access Violation may occur when the following conditions are true:The table has underlying triggers for the INSERT, UPDATE or DELETE.The trigger queries the inserted or deleted trigger tables.The NO_BROWSETABLE option is set ON.The following stack dump appears in the SQL Server 7.0 error log:

———————————————————————Short Stack Dump 0×0041012f Module(sqlservr+1012f) (FHasObjPermissions+37)0×005c4e7f Module(sqlservr+1c4e7f) (CBrowseTablePerms::FSchemaChanged+66) 0×005c5094 Module(sqlservr+1c5094) (CBrowseMode::FSchemaChanged+20) 0×0053a072 Module(sqlservr+13a072) (CStmtSelect::XretExecute+9b)0×0040fd90 Module(sqlservr+fd90) (CMsqlExecContext::ExecuteStmts+11b) 0×0040f7d0 Module(sqlservr+f7d0) (CMsqlExecContext::Execute+16b) ———————————————————————
The following stack dump appears in the SQL Server 2000 error log:

———————————————————————-Short Stack Dump004181A1 Module(sqlservr+000181A1) (FHasObjPermissions+00000050)0056BD62 Module(sqlservr+0016BD62) (CBrowseTablePerms::FSchemaChanged+00000059)0056BFC2 Module(sqlservr+0016BFC2) (CBrowseMode::FSchemaChanged+00000020)005F6F05 Module(sqlservr+001F6F05) (CStmtSelect::XretExecute+000000C2)00413CEE Module(sqlservr+00013CEE) (CMsqlExecContext::ExecuteStmts+000002D2)004133E9 Module(sqlservr+000133E9) (CMsqlExecContext::Execute+000001B6)00412918 Module(sqlservr+00012918) (CSQLSource::Execute+00000331)005F663D Module(sqlservr+001F663D) (ExecTrigger+000000C9)005F6824 Module(sqlservr+001F6824) (ExecAfterTrigs+0000019D)005F6922 Module(sqlservr+001F6922) (ExecAfterTrigsIfAny+0000007A)0041A5ED Module(sqlservr+0001A5ED) (CStmtDML::XretExecuteNormal+0000052A)0041A346 Module(sqlservr+0001A346) (CStmtDML::XretExecute+0000001C)00413CEE Module(sqlservr+00013CEE) (CMsqlExecContext::ExecuteStmts+000002D2)004133E9 Module(sqlservr+000133E9) (CMsqlExecContext::Execute+000001B6)00412918 Module(sqlservr+00012918) (CSQLSource::Execute+00000331)0044AFA7 Module(sqlservr+0004AFA7) (CStmtPrepQuery::XretExecute+00000200)00413CEE Module(sqlservr+00013CEE) (CMsqlExecContext::ExecuteStmts+000002D2)004133E9 Module(sqlservr+000133E9) (CMsqlExecContext::Execute+000001B6)00412918 Module(sqlservr+00012918) (CSQLSource::Execute+00000331)00448916 Module(sqlservr+00048916) (language_exec+000003E1)00411D4C Module(sqlservr+00011D4C) (process_commands+000000E0 Line 712+00000002)41073379 Module(UMS+00003379) (ProcessWorkRequests+0000024A)41073071 Module(UMS+00003071) (ThreadStartRoutine+000000BD)7800A27B Module(MSVCRT+0000A27B) (_unDNameEx+0000484C)77E8758A Module(KERNEL32+0000758A) (FileTimeToSystemTime+0000012F)———————————————————————-
Resolution
SQL Server 2000To 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 theMicrosoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/EN-US/) INF: How to Obtain the Latest SQL Server 2000 Service Pack
SQL Server 7.0To resolve this problem, obtain the latest service pack for Microsoft SQL Server 7.0. For additional information, click the following article number to view the article in theMicrosoft Knowledge Base:
301511?(http://support.microsoft.com/kb/301511/EN-US/) INF: How to Obtain the Latest SQL Server 7.0 Service Pack

FIX: Parallel Hash Join with Empty Result Set Incorrectly Flows Error Back on Client Connection

Symptoms
If you run a SQL Server Data Manipulation Language (DML) statement from a DB-Library based application against a Microsoft SQL Server 7.0 server, the error handler for the application may incorrectly fire and only report the following error message:

DB-LIBRARY Error 10007, Severity 5:
General SQL Server error: Check messages from the SQL Server.Note that this error message accompanies a wide range of SQL Server errors that are reported back to the client from the server. However, in this scenario the preceding error message is the only error reported and it is not accompanied by any other specific error messages.
Resolution
If a parallel hash join produces an empty result set, internal exception 3602 is used to coordinate the shutdown of worker threads that were created to process the parallel hash plan. The internal 3602 exception is an internal control exception that is used to direct processing flow inside SQL Server and is expected behavior in this case.
However, the fact that it is causing an error to be sent back on the client connection, which in turn causes the DB-Library error handler to fire is not expected behavior.

Error message occurs in SQL Server 7.0 when you call the Command.Prepare method before you add parameters by using Visual C# .NET: “An unhandled exception of type”

Symptoms
When you create a parameterized command against Microsoft SQL Server 7.0, if you call the Prepare method before you add parameters to the command, you receive the following error message:

An unhandled exception of type ‘System.Data.SqlClient.SqlException’ occurred in system.data.dll.
Additional information: System error. This problem does not occur in SQL Server 2000.
Resolution
This problem occurs in SQL Server 7.0 because, by design, you cannot run the Prepare method before you add parameters. This applies to most database systems.
SQL Server 2000 does not generate the above-mentioned exception because it does not run Prepare until the first command is executed. This optimization prevents the overhead of Prepare if no commands are subsequently executed.

Description of Service Pack 4 for SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0

Symptoms
This release of Microsoft SQL Server 7.0 and Microsoft Data Engine (MSDE) 1.0 Service Pack 4 (SP4) provides updates for the database components of a SQL Server 7.0 or MSDE 1.0 installation. This article introduces the following information about SP4:
Service Pack versions and the removal of Service Pack 4
How to download andto extract Service Pack 4
How to install Service Pack 4
How to redistribute database components and Service Pack 4 client components
Explains the issues of running Service Pack 4 that affect sites
Resolution
IntroductionService pack versionsRemoving SP4Downloading and extracting SP4Disk space requirements for SP4Extracting Database Components SP4Service pack installationBack up SQL Server databasesMake sure the system databases have sufficient free spacePrepare cluster configurationsStop applications before you run the Service Pack 4 Setup programInstall Database Components SP4Restart servicesRecluster a cluster configurationRestart applicationsInstalling on replicated serversInstalling SP4 on a server that provides a remote distribution database for merge publicationsUpgrading a merge Publisher that receives new subscriptions to SP4 from the original release of SQL Server 7.0Installing SP4 on a merge replication SubscriberRunning SP4 replication with earlier versions of SQL ServerUpdating Access 2000 (Jet 4.0) merge replication SubscribersRedistributing Database Components SP4 client componentsDocumentation notesUpgrading client-only computers after you install SP4Upgrading Japanese database servers to Windows 2000 after you install SP4Applying SP4 to a later versionInstalling SP4 on Windows NT 4.0, Terminal Server EditionNew Troubleshooting GuideReplication enhancements Optimizing replication synchronization Performance enhancements for merge processing of the initial snapshot Merge metadata cleanupChanges in Database Components New database option New sqlservr startup option Change in cursor behavior Changes in SQL Server ProfilerSQL Server clustering white paperData Transformation ServicesExporting to Oracle databasesUsing the DTS Test featureChanges to the Execute Package dialog boxData Transformation Services error messagesUse of the Set keyword in Microsoft Visual Basic scriptsChanges in DTS packages SQL Server Agent proxy account improvementsSQL Server 7.0 and Exchange 5.5The French version of SQL Server Books OnlineRepository changesImporting from DB2 and Informix databasesImproved retrieval of versioned objects

Considerations for the “autogrow” and “autoshrink” settings in SQL Server

Symptoms
The default autogrow and autoshrink settings will work for you with no tuning on many SQL Server systems. However, there are environments where you do not have to turn the settings on or where you may have to adjust the autogrow and autoshrink parameters. This article gives you some background information to guide you when you select the settings for your environment.
Resolution
Here are some things to consider if you decide to tune your autogrow and autoshrink parameters.How do I configure the settings?You can configure the autogrow and autoshrink settings by using one of the following:An ALTER DATABASE statement (not available in SQL Server 7.0)SQL Server Management Studio or SQL Enterprise ManagerThe sp_dboption stored procedure (deprecated in SQL Server 2005)Note If you are using SQL Server 2005, use SQL Server Management Studio instead ofSQL Enterprise Manager. For more information about how to set these settings in SQL Server 2005, visit the following Microsoft Developer Network (MSDN) Web sites:
How to: Add Data or Log Files to a Database (SQL Server Management Studio)
http://msdn2.microsoft.com/en-us/library/ms189253.aspx(http://msdn2.microsoft.com/en-us/library/ms189253.aspx)
Database Properties (Files Page)
http://msdn2.microsoft.com/en-us/library/ms180254.aspx(http://msdn2.microsoft.com/en-us/library/ms180254.aspx)You can also configure the autogrow option when you create a database.
You can view the current settings through the database properties in SQL Enterprise Manager (SEM). Or, you can run the following Transact-SQL command:

sp_helpdb [ [ @dbname= ] ‘name’ ]Keep in mind that the autogrow settings are per file. Therefore, you have to set them in at least two places for each database (one for the primary data file and one for the primary log file). If you have multiple data and/or log files, you must set the options on each file. Depending on your environment, you may end with different settings for each database file.What are the performance implications?If you run a transaction that requires more log space than is available, and you have turned on the autogrow option for the transaction log of that database, then the time it takes the transaction to complete will include the time it takes the transaction log to grow by the configured amount. If the growth increment is large or there is some other factor that causes it to take a long time, the query in which you open the transaction might fail because of a timeout error. The same sort of issue can result from an autogrow of the data portion of your database. To change your autogrow configuration, see the “ALTER DATABASE” topic in SQL Server Books Online.If you run a large transaction that requires the log to grow, other transactions that require a write to the transaction log will also have to wait until the grow operation completes.If you combine the autogrow and autoshrink options, you might create unnecessary overhead. Make sure that the thresholds that trigger the grow and shrink operations will not cause frequent up and down size changes. For example, you may run a transaction that causes the transaction log to grow by 100 MB by the time it commits. Some time after that the autoshrink starts and shrinks the transaction log by 100 MB. Then, you run the same transaction and it causes the transaction log to grow by 100 MB again. In that example, you are creating unnecessary overhead and potentially creating fragmentation of the log file, either of which can negatively affect performance.Physical fragmentation from changing the size of the data or log files can have a severe affect on your performance. This is true whether you use the automatic settings or whether you manually grow and shrink the files frequently.If you grow your database by small increments, or if you grow it and then shrink it, you can end up with disk fragmentation. Disk fragmentation can cause performance issues in some circumstances. A scenario of small growth increments can also reduce the performance on your system.Best PracticesFor a managed production system, you must consider autogrow to be merely a contingency for unexpected growth. Do not manage your data and log growth on a day-to-day basis with autogrow.You can use alerts or monitoring programs to monitor file sizes and grow files proactively. This helps you avoid fragmentation and permits you to shift these maintenance activities to non-peak hours.AutoShrink and autogrow must be carefully evaluated by a trained Database Administrator (DBA); they must not be left unmanaged.Your autogrow increment must be large enough to avoid the performance penalties listed in the previous section. The exact value to use in your configuration setting and the choice between a percentage growth and a specific MB size growth depends on many factors in your environment. A general rule of thumb to you can use for testing is to set your autogrow setting to about one-eight the size of the file.Turn on the <MAXSIZE> setting for each file to prevent any one file from growing to a point where it uses up all available disk space.Keep the size of your transactions as small as possible to prevent unplanned file growth.Why do I have to worry about disk space if size settings are automatically controlled?The autogrow setting cannot grow the database size beyond the limits of the available disk space on the drives for which files are defined. Therefore, if you rely on the autogrow functionality to size your databases, you must still independently check your available hard disk space. The autogrow setting is also limited by the MAXSIZE parameter you select for each file. To reduce the possibility of running out of space, you can monitor the Performance Monitor counter SQL Server: Databases Object :D ata File(s) Size (KB) and set up an alert for when the database reaches a certain size.Unplanned growth of data or log files can take space that other applications expect to be available and might cause those other applications to experience problems.The growth increment of your transaction log must be large enough to stay ahead of the needs of your transaction units. Even with autogrow turned on, you can receive a message that the transaction log is full, if it cannot grow fast enough to satisfy the needs of your query.SQL Server does not constantly test for databases that have hit the configured threshold for autoshrink. Instead, it looks at the available databases and finds the first one that is configured to autoshrink. It checks that database and shrinks that database if needed. Then, it waits several minutes before checking the next database that is configured for autoshrink. In other words, SQL Server does not check all databases at once and shrink them all at once. It will work through the databases in a round robin fashion to stagger the load out over a period of time. Therefore, depending on how many databases on a particular SQL Server instance you have configured to autoshrink, it might take several hours from the time the database hits the threshold until it actually shrinks.