1.select @@identity;
2.select max(id) from tablename;

解决方案 »

  1.   

    select identitycol  from tablename
      

  2.   

    to:tj_dns(愉快的登山者)
    我试过了,结果全是null亚
      

  3.   

    select identitycol from tablename是可以的,@@identity 是返回最后插入行的标识列的列值的。
      

  4.   

    select identitycol from tablename是查出表中自增字段列值;select @@identity是在insert后查出插入的@@identity值,我现在就是需要再不进行insert的操作情况下查到这个值。不能用max,那是查当前的最大值,不是要插入的@@identity值。