Sunday, February 12, 2012

Are there any difference in 7 and 2000 regarding set ansi_padding?

Are there any difference between SQL Server 7 and SQL Server 2000 regarding
the set ansi_padding?
I have the following script:
set ansi_padding on
declare @.x integer
select @.x = 1
select case when @.x = 1 then 'test ' else 'test2 ' end + 'result'
Running the script in SQL Server 2000 will get this:
test result
Running the script in SQL Server 7 will get this:
testresult
Why are the results be different?no difference that I'm aware of, checkout KB articles:
INF: Behavior of ANSI_PADDING - ID: 154886
INF: Insertion of Strings Containing Trailing Spaces - ID: 231830
Are you running this from the same client machine and same application? If
not - try the same test from the same test box and from the same client
application.
additional references:
PRB: ALTER COLUMN Sets TrimTrailingBlanks Property to NO - ID: 296559
Fany Vargas
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.
Are you secure? For information about the Strategic Technology Protection
Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.
Microsoft highly recommends that users with Internet access update their
Microsoft software to better protect against viruses and security
vulnerabilities. The easiest way to do this is to visit the following
websites:
http://www.microsoft.com/protect
http://www.microsoft.com/security/guidance/default.mspx|||Hi Fany,
I have identified that the issue is related to the CASE statement in SQL
Server 7.
1. If the WHEN expression is true and the length of the ELSE value is <= to
the the length of the THEN value, the THEN value won't get trimmed.
2. If the WHEN expression is not true and the length of the THEN value is <=to the length of the ELSE value, the ELSE value won't get trimmed.
SQL Server 2000 will behave like this if set ansi_padding is set to OFF.
Thanks,
"Fany Vargas [MSFT]" wrote:
> no difference that I'm aware of, checkout KB articles:
> INF: Behavior of ANSI_PADDING - ID: 154886
> INF: Insertion of Strings Containing Trailing Spaces - ID: 231830
> Are you running this from the same client machine and same application? If
> not - try the same test from the same test box and from the same client
> application.
> additional references:
> PRB: ALTER COLUMN Sets TrimTrailingBlanks Property to NO - ID: 296559
>
> Fany Vargas
> Microsoft Corporation
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Are you secure? For information about the Strategic Technology Protection
> Program and to order your FREE Security Tool Kit, please visit
> http://www.microsoft.com/security.
> Microsoft highly recommends that users with Internet access update their
> Microsoft software to better protect against viruses and security
> vulnerabilities. The easiest way to do this is to visit the following
> websites:
> http://www.microsoft.com/protect
> http://www.microsoft.com/security/guidance/default.mspx
>

No comments:

Post a Comment