zoukankan      html  css  js  c++  java
  • 获取数据库中的所有用户表、取数据表的描述信息包括描述说明

    --获取所有数据库名
    Select Name FROM Master..SysDatabases ORDER BY Name
    
    --获取指定数据库的所有表(DatabaseName 替换成指定库名即可)
    use DatabaseName select table_name  from information_schema.columns group by table_name
    
    --获取数据库中所有的用户表
     Select Name FROM SysObjects Where XType='U' orDER BY Name
    
    --获取数据库中数据表所有字段 (将tbName替换成你的表名即可)
    select    a.*   from   syscolumns   a,   sysobjects   b   where   a.id=b.id   and   b.name= 'ContentInfo'

     //code by:博客园-曹永思-在线起名

    --获取数据表的详细信息  (将tbName替换成你的表名即可)
    SELECT CASE WHEN EXISTS (SELECT 1 FROM sysobjects WHERE xtype='PK' AND parent_obj = a.id 
    AND name IN (SELECT name FROM sysindexes WHERE indid IN (SELECT indid FROM sysindexkeys
     WHERE id = a.id AND colid = a.colid))) THEN '1' ELSE '0' END AS 'key', 
    CASE WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN '1' ELSE '0' END AS 'identity', a.name AS ColName,
     c.name AS TypeName, a.length AS 'byte', 
    COLUMNPROPERTY(a.id, a.name, 'PRECISION') AS 'length',
     a.xscale, a.isnullable, ISNULL(e.text, '') AS 'default', 
    ISNULL(p.value, '') AS 'comment'
    FROM sys.syscolumns AS a INNER JOIN
                          sys.sysobjects AS b ON a.id = b.id INNER JOIN
                          sys.systypes AS c ON a.xtype = c.xtype LEFT OUTER JOIN
                          sys.syscomments AS e ON a.cdefault = e.id LEFT OUTER JOIN
                          sys.extended_properties AS p ON a.id = p.major_id AND a.colid = p.minor_id
    WHERE     (b.name = 'ContentInfo') AND (c.status <> '1')
    
    --获取自增的字段名称(将 tbName 替换成你的表名即可)
    select [name] from syscolumns where
    id=object_id(N'tbName') and COLUMNPROPERTY(id,name,'IsIdentity')=1

    ROW_NUMBER 方式分页语句: select * from(select  ROW_NUMBER()  over(order by AreaId desc) as rn,
     [AreaId],[ParentId],[Sort],[AreaName],[PingYin]
    from Aqioo_Area a where 1=1 and PingYin like '%g')  b where rn<(2*6+1) and rn>(2-1)*6 
     
    --将表的标识回滚到从0开始
    DBCC CHECKIDENT(表名,RESEED,0)

     根据存储过程名称获取存储过程参数的方法:

    "SELECT  P.name,'' as value  FROM    sys.parameters P  INNER JOIN sys.objects O ON O.object_id = P.object_id
                                                            WHERE   O.type = 'P' AND P.is_output = 0
                                                                    AND O.name = '" + storedProc + "'
     

     欢迎转载,转载请注明出处,希望帮到更多人。

  • 相关阅读:
    10分钟学会React Context API
    Soft skill
    前端-页面性能调试:Hiper
    js对secure的支持是没问题的,httponly是为限制js而产生的,当然httponly的cookie也不会被js创建
    关于go的不爽
    Windows上mxnet实战深度学习:Neural Net
    wget获取https资源
    使用windows上 mxnet 预编译版本
    NVIDA 提到的 深度框架库
    Windows下编译mxnet
  • 原文地址:https://www.cnblogs.com/yonsy/p/2651667.html
Copyright © 2011-2022 走看看