Use the following stored procedure: If the input table name is used, the table is taken out. If the table name is not used, the entire table structure is selected. If you have any questions, continue to ask me. -- This stored procedure retrieves the field information of the input table. If the table name is blank, it lists information about all the tables in the current database, -- If the @ withview parameter is not 0, the field information of the view is listed. If the parameter is 0, no view information is listed. Create Procedure [ DBO ] . [ Table_info ] ( @ Tablename Varchar (50 ), @ Withview Bit = 0 ) As Begin If Not Exists ( Select * From DBO. sysobjects Where ID= Object_id (N ' [DBO]. [datadict] ' ) And Objectproperty (ID, n ' Isusertable ' ) = 1 ) Begin If @ Tablename Is Null Begin If @ Withview = 0 Begin Select Case O. Type When ' V ' Then ' View: ' + O. Name Else ' Table: ' + O. Name End As Table Name, C. Name As Column name, T. Name As Type, C. Length As Length, C. prec As Precision, C. Scale As Decimal places, Case C. isnullable When 0 Then ' Yes ' Else ' No ' End As Can it be blank? From SYS. syscolumns As C Inner Join SYS. policypes As T On C. xusertype = T. xusertype Inner Join SYS. sysobjects As O On C. ID = O. ID Where (O. Type = ' U ' ) And (O. Name Not In ( ' Sysconstraints ' , ' Syssegments ' )) Order By O. type, O. Name, column name End Else Begin Select Table Name = Case O. Type When ' V ' Then ' View: ' + O. Name Else ' Table: ' + O. Name End , C. Name As Column name, T. Name As Type, C. Length As Length, C. prec precision, C. Scale As Decimal places. Can it be blank? = Case C. isnullable When 0 Then ' Yes ' Else ' No ' End From Syscolumns C, sysobjects o, policypes t Where T. xusertype = C. xusertype And O. ID = C. ID And (O. Type = ' U ' Or O. Type = ' V ' ) And O. Name Not In (' Sysconstraints ' , ' Syssegments ' ) Order By O. type, O. Name, C. Name End End Else Begin Select C. Name As Column name, T. NameAs Type, C. Length As Length, C. prec As Precision, C. Scale As Decimal places, Case C. isnullable When 0 Then ' Yes ' Else ' No ' End As Can it be blank? From SYS. syscolumns As C Inner Join SYS. policypes As T On C. xusertype = T. xusertype Inner Join SYS. sysobjects As O On C. ID = O. ID Where (O. Name = @ Tablename ) Order By O. type, O. Name, column name End End Else Begin If Not @ Tablename Is Null Begin Select @ Tablename As Table Name, A. Name As Column name, C. Explain As Description: B. Name As Data Type, A. Length As Length, A. xprec As Precision, A. XScale As Decimal places From Syscolumns Join Policypes As B On B. xtype = A. xtype Right Join Datadict As C On C. Fields = A. Name Where ID = Object_id ( @ Tablename ) And C. tablename = @ Tablename Order By A. Name End Else Begin Select Table Name = Case O. Type When ' V ' Then ' View: ' + O. Name Else ' Table: ' + O. Name End , A. Name As Column name, C. Explain As Description: B. Name As Data Type, A. Length As Length, A. xprec As Precision, A. XScale As Decimal places From Syscolumns Join Policypes As B On B. xusertype = A. xusertype Right Join DatadictAs C On C. Fields = A. Name Right Join Sysobjects As O On C. tablename = O. Name Where A. ID = O. ID And (O. Type = ' U ' Or O. Type = ' V ' ) And O. Name Not In ( ' Sysconstraints ' , ' Syssegments ' ) Order By O. type, O. Name, A. Name End End End