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 ‘function’

FIX: Invalid Use of the Getdate Function May Cause Access Violation

Symptoms
An invalid use of the Getdate function within a function may cause an access violation and the following error message appears in Query Analyzer:

Server: Msg 443, Level 16, State 1, Procedure fnTestDate, Line 4
Invalid use of ‘getdate’ within a function.
ODBC: Msg 0, Level 19, State 1
SqlDumpExceptionHandler: Process 51 generated fatal exception c0000005
EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.
Connection BrokenYou may find the following error messages in the SQL Server error log when the access violation occurs:

00603513 Module(sqlservr+00203513) (walk_exp_tree+00000016)006034BD Module(sqlservr+002034BD) (get_expression_str+00000038)005C679A Module(sqlservr+001C679A) (yyparse+0000145C)00444BEC Module(sqlservr+00044BEC) (sqlpars+0000003C)00411685 Module(sqlservr+00011685) (CSQLSource::FTransform+0000013C)00449527 Module(sqlservr+00049527) (CSQLStrings::FTransform+000001A1)00413632 Module(sqlservr+00013632) (CSQLSource::Execute+0000015B)0044912C Module(sqlservr+0004912C) (language_exec+000003E1)00412B1F Module(sqlservr+00012B1F) (process_commands+000000E0)41073537 Module(UMS+00003537) (ProcessWorkRequests+0000024A)41073355 Module(UMS+00003355) (ThreadStartRoutine+000000BC)7800A27B Module(MSVCRT+0000A27B) (beginthread+000000CE)77DB2C18 Module(KERNEL32+00002C18) (GetModuleHandleA+0000007A)
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 theMicrosoft Knowledge Base:
290211?(http://support.microsoft.com/kb/290211/EN-US/) INF: How to Obtain the Latest SQL Server 2000 Service Pack

FIX: Error message when you execute a user-defined function in SQL Server 2005: “Invalid length parameter passed to the SUBSTRING function” or “A transport-level error has occurred when receiving …

Symptoms
This article describes the following about this hotfix release:The issues that are fixed by this hotfix packageThe prerequisites for installing the hotfix packageInformation about whether you must restart the computer after you install the hotfix packageInformation about whether the hotfix package is replaced by any other hotfix packageInformation about whether you must make any registry changesThe files that are contained in the hotfix package
Resolution
When you execute a user-defined function in SQL Server 2005, you receive an error message. This problem occurs if you run the following statement before you execute the user-defined function:

SET FMTONLY ONYou receive a different error message, depending on the version of SQL Server 2005 that you have installed. If you use SQL Server 2005 Service Pack 1 (SP1), you may also experience other problems.
The original release version of SQL Server 2005When you execute the user-defined function in the original version of SQL Server 2005, you receive the followingerror message.

Msg 536, Level 16, State 5, Line 4
Invalid length parameter passed to the SUBSTRING function.
SQL Server 2005 SP1When you execute the user-defined function in SQL Server 2005 SP1, you experience the following problems:You receive the following error message:

Msg 109, Level 20, State 0, Line 0
A transport-level error has occurred when receiving results from the server. (provider: Shared Memory Provider, error: 0 – The pipe has been ended.)The SQL Server service stops.The following access violation is logged in the SQL Server Errorlog file:

SqlDumpExceptionHandler: Process 53 generated fatal exception c0000005 EXCEPTION_ACCESS_VIOLATION. SQL Server is terminating this process.

BUG: Restore of a Large Database on Windows 98 May Fail with 3257 Error Message

Symptoms
Restoring a database backup on Microsoft Windows 98 fails if all the following conditions are met:The file size of the restored database is 2 GB or greater.
The database is being restored over an existing database that is less than 2 GB even if there is more than 2 GBs of free disk space.Here is an example of the error message that might occur:

Server: Msg 3257, Level 16, State 1, Line 1
There is insufficient free space on disk volume ‘D:\MSSQL7\DATA’ to create the database. The database requires 2352873472 additional free bytes, while only 2147155968 bytes are available.
Server: Msg 3013, Level 16, State 1, Line 1
Backup or restore operation terminating abnormally.This error message occurred while attempting to restore a 2 GB database over a newly created or existing database that was less than 2 GB. The restored database file (.mdf) would have been 2,352,873,472 bytes in size.
Resolution
On Microsoft Windows 98, a different Win32 function is called to determine how much free space is available. The function that is called returns a maximum of 2 GB free space.
For additional information about the Win32 function, click the article number below to view the article in the Microsoft Knowledge Base:
231497?(http://support.microsoft.com/kb/231497/EN-US/) INF : Understanding and Using GetDiskFreeSpace and GetDiskFreeSpaceEx