February 17, 2004 at 3:32 pm
I have a table with 1 column defined as char(10). The table has 1 null row in it. When I run this statement: select datalength(isnull(column1,'')) - it returns 10. When I run the same query on the same table in a different database on the same server, it returns 0. This is SQL Server 2000 SP3. The db compat level (as defined by sp_dbcmptlevel) on both databases is 80. Anyone have any guesses what might cause this? Thanks in advance! - apf
February 18, 2004 at 8:57 am
Are you sure the other column is also CHAR(10)? I would expect a 0 for a VARCHAR type column and 10 for a CHAR(10) column (remember CHAR columns are padded to the length they are set for).
-SQLBill
February 18, 2004 at 9:32 am
Yes, I'm sure. As a matter of fact the DDL for one table was generated from the other (obviously, I tried to simplify the situation). The column in question is defined as char(10) nullable. My theory is that the original table's database was created when the server was 7.0. I know that datalength behaves differently from 7.0 to 2000. I'm going to try dropping and recreating the original table and see if the query then returns 0. - Thanks for your quick reply! - apf
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply