Super useful SQL statements (for SQLSERVER server) super useful SQL statements, after execution, the returned columns are: Table Name, column name, column type, column length, column description, whether the primary key, the statement is as follows: (dedicated to analyzing the database table structure) the following is SQLSERVER2000SelectSysobjects. nameAs table
Extremely useful SQL statements (for SQL SERVER servers). After execution, the returned columns are: the following statements describe the table name, column name, column type, column length, column description, and whether the primary key is used: (used to analyze the SQL SERVER database table structure) SQLSERVER2000 Select Sysobjects. name As table
SuperUsefulSQLStatement(For SQL SERVER servers)
SuperUsefulSQLStatementThe columns returned after execution are: Table Name, column name, column type, column length, column description, and whether the column is a primary key,StatementAs follows:
(AnalysisSQL SERVERDatabaseTableStructureDedicated)
Below is SQLSERVER2000
Select Sysobjects. Name As table Name,
Syscolumns. Name As column Name,
Policypes. Name As column type,
Syscolumns. Length As column Length,
Isnull (Sysproperties. Value, Syscolumns. Name) As column description,
Case
When Syscolumns. Name In
(Select primary key = A. Name
From Syscolumns
Inner Join Sysobjects B On A. Id = B. Id
And B. Xtype = 'U'
And B. Name <> 'dtproperties'
Where Exists (Select 1
From Sysobjects
Where Xtype = 'pk'
And Name In
(Select Name
From Sysindexes
Where Indid In
(Select Indid
From Sysindexkeys
Where Id = A. Id
And Colid = A. Colid )))
And B. Name = Sysobjects. Name) Then
1
Else
0
Whether the End As primary key is used
From Sysobjects, policypes, Syscolumns
Left Join Sysproperties On (Syscolumns. Id = Sysproperties. Id And
Syscolumns. Colid = Sysproperties. Smallid)
Where (Sysobjects. Xtype = 'U' Or Sysobjects. Xtype = 'V ')
And Sysobjects. Id = Syscolumns. Id
And policypes. Xtype = Syscolumns. Xtype
And policypes. Name <> 'sysname'
And Sysobjects. Name Like '%'
Order By Sysobjects. Name, Syscolumns. Colid
The following are the versions of SQLSERVER 2005Statement
Select Sysobjects. Name As table Name,
Syscolumns. Name As column Name,
Policypes. Name As column type,
Syscolumns. Length As column Length,
Isnull (sys. extended_properties.Value, Syscolumns. Name) As column description,
Case
When Syscolumns. Name In
(Select primary key = A. Name
From Syscolumns
Inner Join Sysobjects B On A. Id = B. Id
And B. Xtype = 'U'
And B. Name <> 'dtproperties'
Where Exists (Select 1
From Sysobjects
Where Xtype = 'pk'
And Name In
(Select Name
From Sysindexes
Where Indid In
(Select Indid
From Sysindexkeys
Where Id = A. Id
And Colid = A. Colid )))
And B. Name = Sysobjects. Name) Then
1
Else
0
Whether the End As primary key is used
From Sysobjects, policypes, Syscolumns
Left Join sys. extended_properties On (Syscolumns. Id = sys. extended_properties.major_id And
Syscolumns. Colid = sys. extended_properties.minor_id)
Where (Sysobjects. Xtype = 'U' Or Sysobjects. Xtype = 'V ')
And Sysobjects. Id = Syscolumns. Id
And policypes. Xtype = Syscolumns. Xtype
And policypes. Name <> 'sysname'
And Sysobjects. Name Like 'xjy %'
Order By Sysobjects. Name, Syscolumns. Colid