select column_name from OPENROWSET(
'SQLOLEDB',
'SERVER=服务器名;uid=连接用户名;pwd=密码;Database=数据库名','SET FMTONLY  OFF; exec sp_columns 表名') as a
where type_name = 'int identity'

解决方案 »

  1.   

    select identity列名=name from syscolumns where status=0x80 and id=object_id(N'你要查的表名')
      

  2.   

    联机帮助:syscolumns
    status tinyint 用于描述列或参数属性的位图: 
    0x08 = 列允许空值。
    0x10 = 当添加 varchar 或 varbinary 列时,ANSI 填充生效。保留 varchar 列的尾随空格,保留 varbinary 列的尾随零。
    0x40 = 参数为 OUTPUT 参数。
    0x80 = 列为标识列。
     
      

  3.   

    to ALL:
    谢谢各位先,我现在是知道表名(table1)想通过SQL语句知道该表中是否有identity字段存在,
    若有的话,将字段名列出来。还望各位大哥多多指教。
                         谢谢!
      

  4.   

    --就是这个嘛select identity列名=name from syscolumns where status=0x80 and id=object_id(N'你要查的表名')