Home All Groups Group Topic Archive Search About

How to get the defined size of nvarchar column (that of CREATE TABLE)?

Author
26 Aug 2006 12:05 AM
pedestrian via SQLMonster.com
Is it possible to use SQL statement to determine the predefined
size (that was set during CREATE TABLE) of a nvarchar column?

--
Regards,
Pedestrian, Penang.

Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/200608/1

Author
26 Aug 2006 1:18 AM
Roy Harvey
Query INFORMATION_SCHEMA.COLUMNS.CHARACTER_MAXIMUM_LENGTH.  For the
storage length see CHARACTER_OCTET_LENGTH.  There is also syscolumns,
or if using SQL Server 2005 sys.columns, but the INFORMATION_SCHEMA
are more friendly and not so likely to change.

Roy Harvey
Beacon Falls, CT

On Sat, 26 Aug 2006 00:05:06 GMT, "pedestrian via SQLMonster.com"
<u16758@uwe> wrote:

Show quote
>Is it possible to use SQL statement to determine the predefined
>size (that was set during CREATE TABLE) of a nvarchar column?
Author
26 Aug 2006 1:21 AM
Arnie Rowland
For both SQL 2000 and SQL 2005, this should point you in a direction you want:

USE Northwind
GO

SELECT
     TABLE_NAME
   , COLUMN_NAME
   , IS_NULLABLE
   , DATA_TYPE
   , CHARACTER_MAXIMUM_LENGTH
   , NUMERIC_PRECISION
   , NUMERIC_SCALE
FROM   INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Employees'
ORDER BY
     TABLE_NAME
   , ORDINAL_POSITION


Choose only the characteristics you need from the above.


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


Show quote
"pedestrian via SQLMonster.com" <u16758@uwe> wrote in message news:6551d7b38223f@uwe...
> Is it possible to use SQL statement to determine the predefined
> size (that was set during CREATE TABLE) of a nvarchar column?
>
> --
> Regards,
> Pedestrian, Penang.
>
> Message posted via SQLMonster.com
> http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/200608/1
>
Author
26 Aug 2006 5:52 AM
pedestrian via SQLMonster.com
Thanks Roy and Arnie for valuable answer....

--
Regards,
Pedestrian, Penang.

Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/200608/1

AddThis Social Bookmark Button