Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting the length of a column?

Status
Not open for further replies.

pdbowling

Programmer
Mar 28, 2003
267
0
0
US
Good day,
I would like to query from myTable the length that is used to set the length of a column when building the table.

ie:

if myColumn is a varchar(20),
can I select in sql in some manner to get 20 back as a result?

Thanks everyone.
PB


Patrick is a distributor of Republic Magazine ( -free pdf copy downloadable ) and the webmaster of
 
What version of SQL Server are you running? This should work for 2000 and higher.
Code:
SELECT Character_Maximum_Length
FROM Information_Schema.Columns
WHERE Table_Name = 'myTable'
AND Column_Name = 'myColumn'

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top