|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Column sizeHello World,
If Len (Expression) return the length of Expression What will return the size of column ? Thank's in advance. ML How do you define "size of column"? Storage size? If so, use the DATALENGTH() function.
-- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ "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 > > > 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 > > > > 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 > > > 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. :)
Other interesting topics
|
|||||||||||||||||||||||