Article ID: 154886 - View products that this article applies to.
This article was previously published under Q154886
This article discusses the behavior of the SET ANSI_PADDING option available with SQL Server version 6.5 and later.
One of the new SET options introduced with SQL Server 6.5 is ANSI_PADDING. The "What's New in SQL Server 6.5" guide mentions that when ANSI_PADDING is on, Varchar values are padded with blanks and Varbinary values are padded with nulls. Note that this does not mean that all variable columns start behaving like fixed length columns by padding all values entered into the column. It means that if a value is entered in a variable column with trailing blanks or nulls, the trailing blanks or nulls are not automatically removed.
The running of the following script in ISQL/w or Query Analyzer illustrates the behavior of ANSI_PADDING. It builds a table with Char, Varchar and Varbinary columns and inserts values both with and without trailing blanks. The script does this twice, once with ANSI_PADDING on and once with it off, to demonstrate that the trailing blanks are inserted into all columns for the first row when the option is on, and are not inserted when the option is off. It also illustrates that the option does not cause the Varchar columns to be padded out to their full length. It only prevents the truncation of trailing blanks supplied by the user.