存储过程问题!
现有一存储过程:
CREATE proc codeprocess
@startpos bigint,
@endpos bigint,
@insertstr char(1)
as
declare
@code varchar(50)
declare my_cursor cursor for select distinct(code) from code where autoid >= @startpos and autoid<=@endpos
open my_cursor
FETCH NEXT FROM my_cursor into @code
while @@fetch_status=0
begin
insert into intcode(intcode) values (cast(ceiling(rand(checksum(newid()))*10-1) as varchar)+@insertstr+substring(@code,1,12))
FETCH NEXT FROM my_cursor into @code
end
CLOSE my_cursor
DEALLOCATE my_cursor
SET identity_insert codelog on --开关
insert into codelog values(getdate(),@insertstr,@startpos,@endpos)
SET identity_insert codelog off
GO
我已经把identity_insert 设置为on,为什么在查询分析器下还会报如下错误:
"仅当使用了列的列表,并且 IDENTITY_INSERT 为 ON 时,才能在表 'codelog' 中为标识列指定显式值。"
问题点数:20、回复次数:3Top
1 楼firefox_1983(钱!钱!钱!)回复于 2005-08-02 11:00:16 得分 0
在codelog 表中有一个自增的字段autoid.Top
2 楼vivianfdlpw()回复于 2005-08-02 13:21:29 得分 20
insert into codelog values(getdate(),@insertstr,@startpos,@endpos)
==============>
insert into codelog (字段列表........)
values(getdate(),@insertstr,@startpos,@endpos)
Top
3 楼firefox_1983(钱!钱!钱!)回复于 2005-08-02 14:04:16 得分 0
没有错误了 但是没有写进数据!Top




