我有一个账号数据表
Account Name Password
1       aa   qqq
2       bb   ppp
.................
.................
.................Account 是Key键,怎么写插入一行的SQL语句,Account自动+1还有个角色表
CharactorId   CharName 
1              ffff
.......................
.......................
.......................
插入的行均CharactorId  CharName  不能相同
高手给个高效的SQL插入语句...........在线=ing

解决方案 »

  1.   

    Account可以设置为自增列identity
    CharactorId,CharName使用唯一约束至于你说的高效插入,不知道你要怎么高效
      

  2.   

    俺不懂SQL,只想要个现成的SQl语句。。,3Q, 3Q...
      

  3.   

    create table FrameWork_User
    (
      Account int identity(1,1) primary key,
      Name varchar(30) not null,
      Password varchar(30),
      unique(Name,Password)
    )
    gocreate table FrameWork_Role
    (
      CharactorId int,
      CharName varchar(50),
      unique(CharactorId,CharName)
    )
    goinsert into FrameWork_User(Name,Password) values('Programmer','Programmer')通过上面两个建表的语句所建立的表就能够满足自增和唯一约束的要求,下面的插入语句是向用户表中插入数据的SQL语句
      

  4.   

    if object_id('tb') is not null
    drop table tb
    go
    create table tb(id int identity(1,1) primary key,name varchar(20))
      

  5.   

    你借鉴一下看看,很好的
    http://topic.csdn.net/u/20100205/11/65c2f49a-0b4a-44fa-b4bf-2626edc03189.html
      

  6.   

    print(convert(varchar(120),getdate(),120)) 
    ;with cte
    as
    (
    select row_number() over(order by getdate()) as id 
    from syscolumns a,syscolumns b
    )select id into tb from cte where id <=20000
    print(convert(varchar(120),getdate(),120)) 
    --2010-02-05 11:33:24
    --2010-02-05 11:33:24
    --select * from tb