zoukankan      html  css  js  c++  java
  • SqlServer中使用Tsql找出identity列

          有没有方法找出DataBase中所有表的Identity列?可以的,有下面几种T-SQL可以实现:
    第一种方法:使用columnproperty函数:

    select 
        table_name,column_name 
    from 
        information_schema.columns
    where 
        columnproperty(object_id(table_name),column_name,'isidentity')=1
    order by table_name

    第二种方法:使用sys.all_columns视图:

    select 
        object_name(object_id),name 
    from 
        sys.all_columns 
    where 
        is_identity=1  and objectproperty(object_id,'isusertable')=1

    第三种方法:使用identity_columns视图:

    select 
        object_name(object_id),name 
    from 
        sys.identity_columns 
    where 
        objectproperty(object_id,'isusertable')=1

    希望这篇POST对您有帮助! 


    作者:Petter Liu
    出处:http://www.cnblogs.com/wintersun/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
    该文章也同时发布在我的独立博客中-Petter Liu Blog

  • 相关阅读:
    MyBatis查询没有数据返回值为list还是null--------采坑
    Java弱引用WeakReference详细讲解
    idea debug调试详细教程
    [Docker]Dockerfile指令
    [Docker]Dockerfile定制容器
    [Docker]tomcat 404
    [Docker]容器操作
    [Docker]镜像操作
    [Docker]docker-ce安装
    [CentOS7]安装界面直接修改eth0
  • 原文地址:https://www.cnblogs.com/wintersun/p/1812103.html
Copyright © 2011-2022 走看看