You can query the Stored Procedure script:
Select * From syscomments You can query the table name, view name, and stored procedure name.
Select * From sysobjects
-- Where xtype = 'U' -- table name
-- Where xtype = 'V' -- View name
-- Where xtype = 'pk' -- primary key
-- Where xtype = 'P' -- Stored Procedure [2] method: 1. Get all database names: (1 ),SelectName From master .. sysdatabases order by name 2.Get all table names: (1 ),SelectName From sysobjects where xtype = ''u'' order by name
Xtype = ''u'': indicates all user tables;
Xtype = 's': indicates all system tables; (2 ),SelectName From sysobjects where type = ''u'' and sysstat = ''83'' Note: Generally, only type is required. = ''U'', but sometimes there will be system tables mixed in it (I don't know why), add the following sentence to delete these system tables. 3.Get all field names:
(1 ),SelectName From syscolumns where id = object_id (''tablename '')
(2 ),SelectSyscolumns. Name,Policypes. Name, Syscolumns. isnullable, syscolumns. Length From syscolumns, policypes where syscolumns. xusertype = policypes. xusertype and "syscolumns. ID = object_id (''tablename '') Note:
(A) In order to highlight some important content, several pieces of information are selected for output.
(B) The syscolumns table only contains data type numbers. To obtain the complete name, you need to find it from the categorypes table. Generally, it is better to use xusertype for user data types, there will be no one-to-many cases.
(C) syscolumns. length is the length of the physical memory, so nvarchar, varchar, and Other types are shown in the database as half of this. 4. Obtain the column names of the primary keys in the table: Select Syscolumns. NameFrom Syscolumns, sysobjects, sysindexes, sysindexkeys where syscolumns. id = object_id (''tablename'') and sysobjects. xtype = ''pk'' and sysobjects. parent_obj = syscolumns. ID and sysindexes. id = syscolumns. ID and sysobjects. name = sysindexes. name and sysindexkeys. ID = Syscolumns. ID and sysindexkeys. indid = sysindexes. indid and syscolumns. colid = sysindexkeys. colid
Note: This is found in four system tables. The relationship is complex and can be roughly expressed:
Syscolumns contains the column information and table ID in the table. The sysobjects table contains the primary key name (similar to pk_table) and Table ID. There are primary key names, table IDs, and index numbers. In sysindexkeys, there are table IDs, index numbers, and column numbers. After one item is matched, the column names can be found. You can also use the following to obtain the stored procedure: Exec sp_helptext @ objname = 'guestcomplaintsandnetcommentreport' Exec sp_helptext 'guestcomplaintsandnetcommentreport' Example of obtaining Stored Procedure content by name: Select * From syscomments Select * From sysobjects Where xtype = 'P' Select sobj. ID, sobj. Name, comment. Text From syscomments as comment Inner join sysobjects as sobj On sobj. ID = comment. ID Where sobj. xtype = 'P' And comment. ID = '20140901' To get a table column Name: Select * From sysobjects Where name = 'productstype' Select * From syscolumns Where id = '000000' |