Ask a Question related to Coldfusion Database Access, Design and Development.
-
Blazeix #1
Length of column with 'text' data type
Hi. I'm getting various data about columns in a table by using sp_column.
Everything is working as I expected, except one thing. When I get the length of
a column that is of data type 'text', it returns the number 2147483647 when it
is supposed to return 16. I've played around with this number, and I can't seem
to find any relationship, mainly because it is prime. Is there some way I can
get the actual length of the table?
Blazeix Guest
-
Filter table by column data type
Hello everyone, I'm using VB Script, SQL 2K. Is it possible to create a recordset from a table based on the column data type? Hypothetically,... -
#38805 [NEW]: PDO Truncates Text from SQL Server Text Data Type Field
From: gkrajci at arescorporation dot com Operating system: Windows NT PBMA-WB2 5.2 build 37 PHP version: 5.1.6 PHP Bug Type: ... -
Detect CFQuery Column Data Type
Is it possible to detect the data type of a column in an ODBC Select CFQuery with MS Access or SQL Server? This solution will save me a lot of... -
Using DataFormat to limit length of text in column?
Hi! If I have a column in a datagrid, that contains text (possibly a lot of text) and I only want to display the first 50 chars, can I use... -
#25644 [NEW]: xsl:sort with data-type='text' ... php crashes
From: sparky_industries at mad dot scientist dot com Operating system: Windows 98 PHP version: 4.3.3 PHP Bug Type: XSLT... -
JaredJBlackburn #2
Re: Length of column with 'text' data type
The Text datatype has a maximum length of 231-1 (2,147,483,647) characters.
That should be what the sp_columns is telling you. The DATALENGTH() function
should return the length of a specific text, if that's what you're after.
JaredJBlackburn Guest
-
paross1 #3
Re: Length of column with 'text' data type
I'm not sure why you would expect 16. Take a look at SQL Server Books Online
for the text datatype:
text
Variable-length non-Unicode data in the code page of the server and with a
maximum length of 231-1 (2,147,483,647) characters. When the server code
page uses double-byte characters, the storage is still 2,147,483,647 bytes.
Depending on the character string, the storage size may be less than
2,147,483,647 bytes.
It looks to me like sp_columns is reporting exactly what I would expect it to.
Phil
paross1 Guest
-
JaredJBlackburn #4
Re: Length of column with 'text' data type
@@TEXTSIZE should give you the current setting for the max size of a text.
SET TEXTSIZE sets or changes that setting.
JaredJBlackburn Guest
-
Blazeix #5
Re: Length of column with 'text' data type
[q]Originally posted by: paross1
I'm not sure why you would expect 16.[/q]
Well, I'm using SQL Server Enterprise, and when I specify that a column is
'text' it automatically sets the column length to 16. But if 2^31-1 is actually
the length, I guess i'll stick to that. Thanks for everyone's help.
Blazeix Guest
-
paross1 #6
Re: Length of column with 'text' data type
It looks like you are confusing the length the data in a column with the length
of the data type. Since individual text data type values can be too long to
store in a single data row, they are stored in a collection of pages separate
from the pages holding the data for the other columns of the row. When that is
the case, all that is stored in the data row is a 16-byte pointer. For each
row, this pointer points to the location of the text data.
What Enterprise Manager is reporting as "length" is the length of the pointer
that actually points to the location where the data is actually stored.
Phil
paross1 Guest



Reply With Quote

