如何用SQL语句,获取表中的标列名称

解决方案 »

  1.   


    Select name from syscolumns Where ID=OBJECT_ID('表名')
      

  2.   

    Select name from syscolumns Where ID=OBJECT_ID('表名')
    这是所有的列吧?
    怎么知道是不是标识列呢?
      

  3.   

    Select name from syscolumns Where ID=OBJECT_ID('表名')
    是所有列吧,怎么知道是不是标识列,自动增长的。
      

  4.   

    select a.name as 列名,b.name as 类型 from syscolumns a,systypes b where id IN (select max(id) from sysobjects where xtype='u' and name='tableName1') and a.xtype=b.xtype
      

  5.   

    id int
    test int
    name varchar
    password varchar
    address varcharselect a.name as 列名,b.name as 类型 from syscolumns a,systypes b where id IN (select max(id) from sysobjects where xtype='u' and name='userinfo') and a.xtype=b.xtypeid是自动增长的。
      

  6.   


    Insert(ByRef model As Object, ByVal tableName As String)
    model是数据库实体类(与数据库各字段相对应),然后,用返射获取所有的字段拼接成SQL字符串。
    进行通用的插入操作。
    但是如是自动增长的列,是不用在这里指定的。
    比如id 为自动增长的列。
    insert tablename ([id]) vlaues(@id)
    是出错的,所以我现在想查出标识列(自动增长的列)