Microsoft KB Archive/891116

= FIX: The SET ANSI_PADDING ON option may not work as expected when you run a query that contains a CASE statement in SQL Server 7.0 =

Article ID: 891116

Article Last Modified on 2/14/2007

-

APPLIES TO


 * Microsoft SQL Server 7.0 Standard Edition

-



BUG#:200141 (SQL Server 7.0)



SYMPTOMS
When you run a query that contains a CASE statement in Microsoft SQL Server 7.0, the SET ANSI_PADDING ON option may not work as expected. This problem occurs when the following conditions are true:
 * The CASE statement contains multiple literal character strings.
 * The literal character strings have different lengths.
 * The literal character strings have trailing spaces.

For example, in the following Transact-SQL script, the SELECT statement returns 'test1result'. The SELECT statement should return 'test1 result'. DBCC FREEPROCCACHE GO SET ANSI_PADDING ON GO DECLARE @x integer SET @x = 1 SELECT CASE WHEN @x = 1 THEN 'test1 ' WHEN @x = 2 THEN 'test2 ' ELSE 'test 3 ' END + 'result'



RESOLUTION
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next SQL Server 7.0 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

Prerequisites
You must install SQL Server 7.0 Service Pack 4 (SP4) before you install this hotfix

Restart requirement
You do not have to restart your computer after you apply this hotfix.

Hotfix replacement information
This hotfix does not replace any other hotfixes.

File information
The English version of this hotfix 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 tool in Control Panel. File name                   Version           Date         Time        Size -- Msvcr71.dll                 8.00.21213.00     09-Jun-2003  18:20      352,256 Osql.exe                    8.00.796          09-Jun-2003  18:20       57,904 Sqdedev.dll                 8.00.534          09-Jun-2003  18:20      127,548 Sqlunirl.dll                8.00.194          09-Jun-2003  18:20      180,290 Dbmssocn.dll                7.00.1081         04-Oct-2002  23:59       28,944 Distrib.exe                 7.00.1077         06-Sep-2002  23:55       53,520 Logread.exe                 7.00.1077         06-Sep-2002  23:55       98,576 Opends60.dll                7.00.1093         05-May-2003  18:34      155,920 Rdistcom.dll                7.00.1077         06-Sep-2002  23:56      250,128 Replmerg.exe                7.00.1077         06-Sep-2002  23:55       82,192 Replres.dll                 7.00.1077         06-Sep-2002  23:56       78,096 Securityhotfix.sql                            17-Sep-2002  22:52        7,941 Snapshot.exe                7.00.1077         06-Sep-2002  23:56      160,016 Sp4_serv_uni.sql                              30-May-2003  04:21       59,214 Sqlagent.exe                7.00.1085         15-Jan-2003  01:33      344,064 Sqlcmdss.dll                7.00.1077         06-Sep-2002  23:55       45,056 Sqldmo.dll                  7.00.1094         16-May-2003  00:18    2,629,632 Sqlmap70.dll                7.00.1094         16-May-2003  13:29       81,920 Sqlservr.exe                7.00.1150         15-Dec-2004  01:07    5,062,928 Sqltrace.dll                7.00.1144         15-Oct-2003  17:09      315,392 Ssmsso70.dll                7.00.1081         04-Oct-2002  23:59       45,328 Ssnmpn70.dll                7.00.1094         16-May-2003  00:18       24,848 Ums.dll                     7.00.1079         26-Sep-2002  20:27       57,616 Xpweb70.dll                 7.00.1094         16-May-2003  13:31      151,552 Dbmssocn.dll                7.00.1081         04-Oct-2002  23:59       28,944 Sqldmo.dll                  7.00.1094         16-May-2003  00:18    2,629,632 Sqltrace.dll                7.00.1144         15-Oct-2003  17:09      315,392



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



MORE INFORMATION
This hotfix introduces flag 262. When you enable this trace flag, trailing spaces are no longer truncated from literal strings in CASE statements. To enable trace flag 262, use one of the following methods:   Set trace flags by using the DBCC TRACEON statement. To enable trace flag 262 by using the DBCC TRACEON statement, run the following Transact-SQL script: DBCC TRACEON (262)  Set trace flags at a command prompt. To enable trace flag 262 at startup, type the following command at a command prompt:

sqlservr –d&quot;C:\MSSQL7\Data\master.mdf&quot; –T262





For additional information about the ANSI_PADDING option, visit the following Microsoft Developer Network (MSDN) Web site:

http://msdn2.microsoft.com/en-us/library/aa259201(SQL.80).aspx

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

Keywords: kbsqlserv700presp5fix kbfix kbbug kbhotfixserver kbqfe KB891116

-

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

© Microsoft Corporation. All rights reserved.