Home All Groups Group Topic Archive Search About
Author
1 Oct 2005 2:57 PM
Michel
Hello World,

If Len (Expression) return the length of Expression

What will return the size of column ?


Thank's in advance.

ML

Author
1 Oct 2005 3:11 PM
Tibor Karaszi
How do you define "size of column"? Storage size? If so, use the DATALENGTH() function.

Show quote
"Michel" <m.landr***@wanadoo.fr> wrote in message news:u$8G3hpxFHA.736@tk2msftngp13.phx.gbl...
> Hello World,
>
> If Len (Expression) return the length of Expression
>
> What will return the size of column ?
>
>
> Thank's in advance.
>
> ML
>
>
>
Author
1 Oct 2005 3:16 PM
SQL
The size of a column when created?
use the view INFORMATION_SCHEMA.COLUMNS  and look for column
CHARACTER_MAXIMUM_LENGTH

For the length of data stored in a field you can use DATALENGTH

select DATALENGTH( Fielname) ,FieldName from YourTable

http://sqlservercode.blogspot.com/




Show quote
"Michel" wrote:

> Hello World,
>
> If Len (Expression) return the length of Expression
>
> What will return the size of column ?
>
>
> Thank's in advance.
>
> ML
>
>
>
>
Author
1 Oct 2005 3:27 PM
Michel
A precision,



For exemple,



A column is defined as VARCHAR (10)



The size of column is 10 cars.



What will return 10 (the size of column) ?



Show quote
"Michel" <m.landr***@wanadoo.fr> a écrit dans le message de
news:u$8G3hpxFHA.736@tk2msftngp13.phx.gbl...
> Hello World,
>
> If Len (Expression) return the length of Expression
>
> What will return the size of column ?
>
>
> Thank's in advance.
>
> ML
>
>
>
Author
1 Oct 2005 4:37 PM
ML
Maybe this example can be of help:

use    pubs

select    INFORMATION_SCHEMA.[COLUMNS].CHARACTER_MAXIMUM_LENGTH as DeclaredLength
    ,INFORMATION_SCHEMA.[COLUMNS].CHARACTER_OCTET_LENGTH as ActualLength
    from    INFORMATION_SCHEMA.[COLUMNS]
    where    (INFORMATION_SCHEMA.[COLUMNS].TABLE_NAME = 'authors')


CHARACTER_MAXIMUM_LENGTH is what you are looking for, yet consider also the
CHARACTER_OCTET_LENGTH column for unicode data types.

More on this here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_ia-iz_87w3.asp


ML

p.s. not the same ML obviously. :)

AddThis Social Bookmark Button