Article ID: 296559 - Last Review: October 16, 2003 - Revision: 3.2

PRB: ALTER COLUMN Sets TrimTrailingBlanks Property to NO

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q296559

On This Page

Expand all | Collapse all

SYMPTOMS

When altering an existing varchar column on a table, no matter what the setting is for the ANSI PADDING option at the time of alteration, the TrimTrailingBlanks property for the altered column is always set to NO.

This behavior may potentially break applications that are sensitive to padded spaces.

CAUSE

This behavior is by design. ANSI NULL defaults and ANSI PADDING are always set to ON for an ALTER COLUMN statement. For more information, refer to the "ALTER TABLE (T-SQL)" topic in SQL Server Books Online.

WORKAROUND

Re-create the table and transfer existing data.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Run the following script:
    set ansi_padding off
    go
    create table one (a int, b varchar(50) not null, c varchar(10))
    go
    					


  2. Run the sp_help one stored procedure and it returns:
    Collapse this tableExpand this table
    NullableTrimTrailingBlanks
    aYes(n/a)
    bNoYes
    cYesYes


  3. Run the following script to alter the nullability of column b.
    alter table one alter column b varchar(50) null
    					


  4. Run the sp_help stored procedure one. Note that even though you only wanted to change the nullability, the TrimTrailingBlanks property also changed.
    Collapse this tableExpand this table
    NullableTrimTrailingBlanks
    aYes(n/a)
    bYesNo - has been changed.
    cYesYes

APPLIES TO
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 2000 Standard Edition
Keywords: 
kbprb KB296559