create table #t(id int,colid int,datalen bigint) exec sp_msforeachtable @command1=N' declare @s1 nvarchar(4000),@s2 nvarchar(4000) select @s1='''',@s2='''' select @s1=@s1+'' union all select '' +rtrim(c.id)+'','' +rtrim(c.colid)+'','' +quotename(c.colid)+'' from #'', @s2=@s2+N'',''+quotename(c.colid)+''=max(''+case when t.name in(''sql_variant'',''image'',''money'') or t.name like ''%text'' or t.name like ''%binary'' then ''datalength'' else ''len'' end +''(''+quotename(c.name)+''))'' from syscolumns c,systypes t where c.xusertype=t.xusertype and object_id(''?'')=c.id order by colid select @ s1 = stuff (@ s1, 1, 10, ' ' ' '), @ s2 = stuff (@ s2, 1, 1, ' ' ' ') the exec (' select '+ @ s2 + #' into the from? Insert # t '+ @ s1) =' and '-, @ whereand o.n ame =' to query table ' ' ' SELECT * from table_name where table_name =case when a.colORDER =1 then D.name else "end", =case when a.colORDER =1 then ISNULL (f.value, "") else" end, Case when COLUMNPROPERTY(a.id,a.name,'IsIdentity')=1 THEN '√'else 'end, Primary key =case when exists(SELECT 1 FROM sysobjects where xtype='PK' and parent_obj=a.id and name in (SELECT name FROM sysobjects Sysindexes WHERE indid in(SELECT indid FROM sysindexKeys WHERE id= a.id AND colid= A.colid))) then '√' else 'end, Type = B.name, Occupied bytes = A.length, Length =COLUMNPROPERTY(a.id,a.name,'PRECISION'), maximum length of existing data =data.datalen, COLUMNPROPERTY(a.id,a.name,'Scale'),0), null =case when A.id =1 then '√'else 'end, Default value = isnull (e. ext, ' '), Parameter Description = ISNULL (g.[value], ") FROM syscolumns a inner join #t data on A.id =data.id and a.colid=data.colid left join systypes  b on a.xusertype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' left join syscomments e on a.cdefault=e.id left join sysproperties g on a.id=g.id and a.colid=g.smallid Left join sysproperties f on d.id= F.id and f.mallid =0 --where d.name=' to query 'order by a.id,a.colorder drop table #tCopy the code