SQL语句来获取一个表的所有列的信息,如,列名、类型、长度等

 

SQL语句来获取一个表的所有列的信息,如,列名、类型、长度等
2008-10-31 11:04

本代码适用于: SQLSERVER2000/2005
SQL语句如下:

select c.name, t.name as type, c.length
   ,(
case t.name
    
when ' nvarchar ' then c.length / 2
    
when ' nchar ' then c.length / 2
    
else c.length
  
end )
  
as reallength
from syscolumns c join systypes t
on c.xtype = t.xtype
where t.name <> ' sysname ' and c.id = object_id ( ' Table1 ' )

转自:http://hi.baidu.com/jacksparrow01/blog/item/b53a7626bd84f404918f9de2.html

你可能感兴趣的:(SQL语句来获取一个表的所有列的信息,如,列名、类型、长度等)