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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get native column type?

Status
Not open for further replies.

hmckillop

Programmer
Oct 30, 2001
1,540
GB
Does anyone know if there is a handy proc/function for returning the base type of a column?
I need to return a list of all columns in a table, but only show the actual type as opposed to the User-Defined Data Types.
I know I can look this up in systypes, but I was wondering if there is a built in proc?

Any help appreciated.
Thank you.

"I'm living so far beyond my income that we may almost be said to be living apart
 
do any of my solutions in thread183-930225 help ?

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
I found it in what i was doing, but an extension of what you had would do the job. Thanks

Code:
SELECT dbo.sysobjects.name AS TableName, dbo.syscolumns.name AS ColName,
 dbo.systypes.name + 
'(' + CONVERT(varchar(4), dbo.syscolumns.length)+ ')', 
--added below two items for the custom and native datatypes
type_name(dbo.systypes.xusertype), type_name(dbo.systypes.xtype)
 AS Datatype
FROM dbo.sysobjects INNER JOIN
dbo.syscolumns ON dbo.sysobjects.id = dbo.syscolumns.id INNER JOIN
dbo.systypes ON dbo.syscolumns.xtype = dbo.systypes.xtype
where dbo.sysobjects.name = 'Account'

"I'm living so far beyond my income that we may almost be said to be living apart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top