为了写个自动生动生成代码的工具,需要查询表结构,sql语句如下,sql2005 select C.name AS column_name,P.[name] AS column_data_type,C.max_length,P.[precision],P.scale,c.is_nullable from sys.columns C inner join sys.tables T on C.[object_id]=T.[object_id] left join sys.types P on C.[user_type_id]=P.[user_type_id] --left join sys.computed_columns a on c.[object_id]=a.[object_id] and c.[column_id]=a.[column_id] --left join sys.default_constraints b on c.[object_id]=b.[parent_object_id] and c.[default_object_id]=b.[object_id] where T.[name]='t_Goods'