你的存储过程没仔细看就发现:
你表aid定义的id列是int型的,你怎么插入‘ere’这样的值啊?
你在查查吧

解决方案 »

  1.   

    看的莫名其妙,int型怎么插入字符串,另外我记得是
    create trigger tri_seq
    on aid
    for insert
      

  2.   

    --改这个试试:create trigger tri_seq--创建触发器
    on aid
    for insert 
    as
    begin
    declare @a int
    declare @str char(4)
    declare @sql varchar(1000)
    set @a=0
    set @str=''
    set @sql=''
    while @a<10000
    begin
    select  @str=right('000'+cast( @a as varchar(4)),4)
    set @sql='insert into aid values('+@str+')'
    exec(@sql)
    set @a=@a +1
    end
    end
      

  3.   

    alter trigger tri_seq--创建触发器
    on aid
    for  insert 
    as
    begin
    declare @a int,@str char(4)
    set @a=0
    while @a<10000 
    begin
    select  @str=right('000'+cast( @a as varchar(4)),4)
    exec('insert into  aid values( '+@str+')')
    set @a=@a +1
    end
    endINSTEAD OF 触发器不支持递归
      

  4.   

    是我写错了,但我的表create table aid (id char(4) not null)--建表
      

  5.   

    --不要用exec,那样会引起归递触,这样就行了:--创建表
    create table aid (id char(4) not null)
    go--创建触发器
    create trigger tri_seq
    on aid
    instead of insert 
    as
    begin
    declare @a int,@str char(4)
    set @a=0
    while @a<10000
    begin
    select  @str=right('000'+cast( @a as varchar(4)),4)
    insert into  aid values(@str)  --这里直接这样写
    set @a=@a +1
    end
    end
    go--插入数据
    insert into aid values('ere')
    go--显示结果
    select * from  aid
    go
      

  6.   

    --其实楼主这样处理的速度太慢了,不如直接这样写(我的电脑中仅用了1秒):--创建表
    create table aid (id char(4) not null)
    go--插入10000万条记录
    insert into aid
    select id=right(10000+a.id+b.id+c.id+d.id,4)
    from(
    select id=0 union all select 1
    union all select id=2 union all select 3
    union all select id=4 union all select 4
    union all select id=6 union all select 7
    union all select id=8 union all select 9
    ) a,(
    select id=0 union all select 10
    union all select id=20 union all select 30
    union all select id=40 union all select 40
    union all select id=60 union all select 70
    union all select id=80 union all select 90
    ) b,(
    select id=0 union all select 100
    union all select id=200 union all select 300
    union all select id=400 union all select 400
    union all select id=600 union all select 700
    union all select id=800 union all select 900
    ) c,(
    select id=0 union all select 1000
    union all select id=2000 union all select 3000
    union all select id=4000 union all select 4000
    union all select id=6000 union all select 7000
    union all select id=8000 union all select 9000
    ) d
    order by id
    goselect * from aid
    godrop table aid
      

  7.   


    insert into aid values('33')
    我想不能让33也插入进去,有没有好办法?
      

  8.   

    搞定,多谢 zjcxc(邹建)大哥的提醒。多谢大家大积极参与。
    create trigger tri_seq
    on aid
    instead of insert 
    as
    begin
    declare @a int,@str char(4)
    set @a=0
    while @a<10000
    begin
    select  @str=right('000'+cast( @a as varchar(4)),4)
    insert into  aid values( @str)
    set @a=@a +1
    end
    end
    insert into aid values('ere')