在MSSQL中@@RowCount和@@IDInTITY有什么作用有什么区别
大哥们给给答案

解决方案 »

  1.   

    返回执行上句SQL所影响的行数.
    具体查T-SQL手册
      

  2.   

    ....
    @@IDENTITY???吧??
    IDINTITY 就不知道了..
    这个能得到这一次数据库连接中,最后插入的数据的自增自段的值而@@rowcount是设置取值条数.操作的条数.比如
    set @@ROWCOUNT=10
    select * from onetale
    就只能得到10条.
    然后在set @@rowcount=0去复位下
    就和top 10 有点类似..常用于分页存储过程中
      

  3.   

    @@RowCount最近一个操作所影响记录的条数,@@IDENTITY 最近返回插入到 IDENTITY 列的值
      

  4.   


    if object_id('tb') is not null
    drop table tb
    go
    create table tb(id int identity,name varchar(10))
    insert into tb select 'a'
    insert into tb select 'b'
    insert into tb select 'c'
    insert into tb select 'd'
    insert into tb select 'e'select * from tb
    select @@rowcount --5 表示查询所影响的行数set rowcount 2 --设置影响的行数
    select * from tb order by id-- 查 a,bset rowcount 0 --复位
    insert into tb select 'f'
    select @@identity --查当前会话中的表最后插入的自增列的值