我有以下代码:
declare c cursor for
select
id_user_V3
,device_type
,4
,notfication_mode
,t1.device_token
,registration_date
,rank
,1
from audiv2.dbo.mya_webservice_device_token t1
join migr.asoc_V2_glb_user t2 on t1.user_id = t2.id_user_V2
open c
fetch next from c into @id_user_v3,@type,@application_id,@notiffication,@device_tooken,@creation_date,@rang,@status
while @@FETCH_STATUS=0
begin
set @device_id = (ISNULL((SELECT MAX(id_device) FROM usr_device)+1,1))
SET IDENTITY_INSERT usr_device ON
insert into usr_device values
(
@device_id
,@id_user_v3
,@type
,@application_id
,@notiffication
,@device_tooken
,@creation_date
,@rang
,@status
)
SET IDENTITY_INSERT usr_device OFF
fetch next from c into @id_user_v3,@type,@application_id,@notiffication,@device_tooken,@creation_date,@rang,@status
end
close c
deallocate c
我得到的错误是:
只有在使用列列表并且 IDENTITY_INSERT 为 ON 时,才能为表 'usr_device' 中的标识列指定显式值。
我该如何解决这个问题?
提前致谢