search
HomeDatabaseMysql Tutorial超级有用的SQL语句(分析SQL SERVER 数据库表结构专用)

超级 有用 的SQL 语句 (用于SQL SERVER 服务器) 超级 有用 的SQL 语句 ,执行后返回的列分别是:表名、列名、列类型、列长度、列描述、是否主键, 语句 如下: ( 分析 SQL SERVER 数据库 表 结构 专用 ) 以下是SQLSERVER2000 Select Sysobjects.Name As 表

超级有用的SQL语句 (用于SQL SERVER 服务器)
超级有用的SQL语句 ,执行后返回的列分别是:表名、列名、列类型、列长度、列描述、是否主键,语句如下:

(分析SQL SERVER 数据库结构专用)

 

以下是SQLSERVER2000



Select Sysobjects.Name As 表名,
       Syscolumns.Name As 列名,
       Systypes.Name As 列类型,
       Syscolumns.Length As 列长度,
       Isnull(Sysproperties.Value, Syscolumns.Name) As 列说明,
       Case
         When Syscolumns.Name In
              (Select 主键 = A.Name
                 From Syscolumns A
                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
       End As 是否主键
  From Sysobjects, Systypes, 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 Systypes.Xtype = Syscolumns.Xtype
   And Systypes.Name 'Sysname'
   And Sysobjects.Name Like '%'
 Order By Sysobjects.Name, Syscolumns.Colid

 


以下是SQLSERVER 2005版本的语句


Select Sysobjects.Name As 表名,
       Syscolumns.Name As 列名,
       Systypes.Name As 列类型,
       Syscolumns.Length As 列长度,
       Isnull(sys.extended_properties.Value, Syscolumns.Name) As 列说明,
       Case
         When Syscolumns.Name In
              (Select 主键 = A.Name
                 From Syscolumns A
                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
       End As 是否主键
  From Sysobjects, Systypes, 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 Systypes.Xtype = Syscolumns.Xtype
   And Systypes.Name 'Sysname'
   And Sysobjects.Name Like 'XJY%'
 Order By Sysobjects.Name, Syscolumns.Colid

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
SQL Server使用CROSS APPLY与OUTER APPLY实现连接查询SQL Server使用CROSS APPLY与OUTER APPLY实现连接查询Aug 26, 2022 pm 02:07 PM

本篇文章给大家带来了关于SQL的相关知识,其中主要介绍了SQL Server使用CROSS APPLY与OUTER APPLY实现连接查询的方法,文中通过示例代码介绍的非常详细,下面一起来看一下,希望对大家有帮助。

SQL Server解析/操作Json格式字段数据的方法实例SQL Server解析/操作Json格式字段数据的方法实例Aug 29, 2022 pm 12:00 PM

本篇文章给大家带来了关于SQL server的相关知识,其中主要介绍了SQL SERVER没有自带的解析json函数,需要自建一个函数(表值函数),下面介绍关于SQL Server解析/操作Json格式字段数据的相关资料,希望对大家有帮助。

聊聊优化sql中order By语句的方法聊聊优化sql中order By语句的方法Sep 27, 2022 pm 01:45 PM

如何优化sql中的orderBy语句?下面本篇文章给大家介绍一下优化sql中orderBy语句的方法,具有很好的参考价值,希望对大家有所帮助。

Monaco Editor如何实现SQL和Java代码提示?Monaco Editor如何实现SQL和Java代码提示?May 07, 2023 pm 10:13 PM

monacoeditor创建//创建和设置值if(!this.monacoEditor){this.monacoEditor=monaco.editor.create(this._node,{value:value||code,language:language,...options});this.monacoEditor.onDidChangeModelContent(e=>{constvalue=this.monacoEditor.getValue();//使value和其值保持一致i

地理信息科学专业学生应选择哪种电脑地理信息科学专业学生应选择哪种电脑Jan 13, 2024 am 08:00 AM

推荐适合地理信息科学专业学生用的电脑1.推荐2.地理信息科学专业学生需要处理大量的地理数据和进行复杂的地理信息分析,因此需要一台性能较强的电脑。一台配置高的电脑可以提供更快的处理速度和更大的存储空间,能够更好地满足专业需求。3.推荐选择一台配备高性能处理器和大容量内存的电脑,这样可以提高数据处理和分析的效率。此外,选择一台具备较大存储空间和高分辨率显示屏的电脑也能更好地展示地理数据和结果。另外,考虑到地理信息科学专业学生可能需要进行地理信息系统(GIS)软件的开发和编程,选择一台支持较好的图形处

一文搞懂SQL中的开窗函数一文搞懂SQL中的开窗函数Sep 02, 2022 pm 04:55 PM

本篇文章给大家带来了关于SQL server的相关知识,开窗函数也叫分析函数有两类,一类是聚合开窗函数,一类是排序开窗函数,下面这篇文章主要给大家介绍了关于SQL中开窗函数的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下。

如何使用exp进行SQL报错注入如何使用exp进行SQL报错注入May 12, 2023 am 10:16 AM

0x01前言概述小编又在MySQL中发现了一个Double型数据溢出。当我们拿到MySQL里的函数时,小编比较感兴趣的是其中的数学函数,它们也应该包含一些数据类型来保存数值。所以小编就跑去测试看哪些函数会出现溢出错误。然后小编发现,当传递一个大于709的值时,函数exp()就会引起一个溢出错误。mysql>selectexp(709);+-----------------------+|exp(709)|+-----------------------+|8.218407461554972

Monaco Editor怎么实现SQL和Java代码提示Monaco Editor怎么实现SQL和Java代码提示May 11, 2023 pm 05:31 PM

monacoeditor创建//创建和设置值if(!this.monacoEditor){this.monacoEditor=monaco.editor.create(this._node,{value:value||code,language:language,...options});this.monacoEditor.onDidChangeModelContent(e=>{constvalue=this.monacoEditor.getValue();//使value和其值保持一致i

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment