I was searching an MS-SQL Server 2005 database to make sure that a certain text field was always a multiple of 8 in length. When I ran the following query, I got that several rows were of length 30. But when I investigated those records, I found that they were longer than that.
select distinct len(cast(textfield as varchar)) from tablename
However, if I specify the length of the varchar as something longer(as in the following query), it works fine.
select distinct len(cast(textfield as varchar(1000))) from tablename
Anybody know why it defaults to 30 and if this is a configurable setting?