userID int IDENTITY(1, 1) Not NULL 
Primary KEY
这样就行了,哈哈

解决方案 »

  1.   

    UserID应该唯一吧?
    select (select count(*) from [Users] where UserID<= a.UserID) as [(自增列)],
    UserName,Address,Sex
    from [Users] a
    order by UserID
      

  2.   

    --可以用下面的方法来生成你要的结果
    --但数据多时,效率低,数据多时,还是建议用临时表select UserID=(select count(*) from Users where UserID<=a.UserID)
    ,UserName,Address,Sex
    from Users a
      

  3.   

    如果只查询部分符合条件的:select (select count(*) from [Users] where 条件 and UserID<= a.UserID) as [(自增列)],
    UserName,Address,Sex
    from [Users] a
    where 条件
    order by UserID
      

  4.   

    不好意思看错了,上面的pengda1li是对的
      

  5.   

    不是pengda1li
    是 pengda1i呵呵
      

  6.   

    select identity(int,1,1),username,address,sex into newtable from users
    select * from newtalbe