Microsoft KB Archive/271601

= PRB: REPLACE Sets First String to NULL if Third String is NULL =

Article ID: 271601

Article Last Modified on 10/17/2003

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition
 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q271601



SYMPTOMS
The following query returns NULL although you might expect the query to return the first string, '3', because the second string, 'X', is not contained within the first string. SELECT REPLACE('3', 'X', NULL)



CAUSE
Regardless of whether or not the second string is contained in the first string, if you pass NULL as any argument to the REPLACE function, it returns NULL. One of the first things that the REPLACE function does is to make sure that it is possible to perform the replace. Because replacing a portion of a string with an unknown value results in an unknown value, it is not possible.



MORE INFORMATION
Future versions of Microsoft SQL Server Books Online will include this information.

Keywords: kbprb KB271601

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.