I have a column with VARCHAR datatype in SQL server 2005 database.
When I insert 3 blanks spaces (' ') in the column, the column still shows me that it is empty. It does not show me 3 spaces. Is this correct behaviour?
This column value is NOT NULL as this row does not appear when I select values with column= NULL.
Is my understanding correct ? If so , what can be reason of this behaviour?
Thanks in advance, Mandar
asked Aug 10 '11 at 05:04 AM in Default
If you want to select null values, you can't use the = operator, you should instead use IS NULL.
or to exclude null values SELECT bla FROM ha WHERE col IS NOT NULL
SQL Server right-trims strings, so any number of trailing blanks is stored as empty string.
answered Aug 10 '11 at 05:12 AM
Varchar may 'right-trim' strings depending on your settings.