Bookmark and Share

Wednesday, November 11, 2009

How to get columns type from Query

Sometimes I need to find info about columns in a table using only TSQL, here is a little query :


SELECT 
syscolumns.name AS ColName, 
systypes.name AS ColType, 
syscolumns.length AS ColSize,
syscolumns.isnullable,
systypes.collation
FROM sysobjects INNER JOIN syscolumns 
ON sysobjects.id = syscolumns.id 
INNER JOIN systypes 
ON dbo.syscolumns.xtype = dbo.systypes.xtype 
WHERE 
sysobjects.xtype='U' 
AND sysobjects.name='banners'


And here is the result, banners is a DotNetNuke table:


image

No comments:

Post a Comment