Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Confusion over datatype length

Author  Topic 

ArpitNarula
Starting Member

16 Posts

Posted - 2011-01-17 : 04:13:22
Hi Guys,

A little confusion here:

When i do exec sp_help <<tablename>>
Output:

Colname | Type | Length
C1 | text | 16

However the same table returns this when queried
select a.* from INFORMATION_SCHEMA.COLUMNS a where a.TABLE_NAME = <<tablename>>

Colname | Type | Character_Maximum_Length
C1 | text | 2147483647

What is the differnence and how much long value does this column accept.

And is there a way to limit the output of sp_help. (say only 5 columns)

Thanks

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-01-17 : 04:30:10
Text lists as 16 bytes because that's the size of the pointer (that's stored in the data page) to the LOB data. It can store up to 2 billion characters.

Unless you're using SQL 2000, you shouldn't be using the text data type. Use Varchar(max) instead.

--
Gail Shaw
SQL Server MVP
Go to Top of Page
   

- Advertisement -