1Select Sysobjects.Name As Tb_name, Syscolumns.Name AsCol_name, Systypes.Name As Col_type, Syscolumns.Length As Col_len, Isnull(Sysproperties.Value,Syscolumns.Name) As Col_memo, 2CaseWhen Syscolumns.Name In 3(Select 主键=A.Name 4From Syscolumns A 5InnerJoin Sysobjects B On A.Id=B.Id And B.Xtype='U'And B.Name<>'Dtproperties' 6WhereExists(Select1From Sysobjects Where Xtype='Pk'And Name In ( 7Select Name From Sysindexes Where Indid In( 8Select Indid From Sysindexkeys Where Id = A.Id And Colid=A.Colid 9))) 10And B.Name=Sysobjects.Name 11) 12Then1Else0EndAs Is_key 13 14From Sysobjects,Systypes,Syscolumns 15LeftJoin Sysproperties On (Syscolumns.Id = Sysproperties.Id And 16Syscolumns.Colid = Sysproperties.Smallid) 17 18Where (Sysobjects.Xtype ='U'Or Sysobjects.Xtype ='V') 19And Sysobjects.Id = Syscolumns.Id And Systypes.Xtype = Syscolumns.Xtype 20And Systypes.Name <>'Sysname'And Sysobjects.Name Like'%'OrderBy Sysobjects.Name, Syscolumns.Colid