Why is 30 the default length for VARCHAR when using CAST?

后端 未结 6 559
误落风尘
误落风尘 2020-12-03 16:38

In SQL server 2005 this query

select len(cast(\'the quick brown fox jumped over the lazy dog\' as varchar))

returns 30 as length while the

6条回答
  •  眼角桃花
    2020-12-03 17:10

    I don't know why they chose 30, but it was the same in Sybase SQL Server, which Microsoft's SQL Server was developed from. It seems to be a peculiarity of those RDBMSs as it's not in the SQL standards, and other servers differ in their behaviour.

提交回复
热议问题