0

私は次のコードを持っています:

 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 

私が得るエラーは次のとおりです:

テーブル'usr_device'のID列の明示的な値は、列リストが使用され、IDENTITY_INSERTがONの場合にのみ指定できます。

どうすればこれを解決できますか?

前もって感謝します

4

1 に答える 1

0

INSERT 句ですべての列名を明示的に言及する必要があります

usr_device (col1、col2、...) の値に挿入します

于 2012-11-07T17:15:26.940 に答える