IDENTITY_INSERT Fails - Why?

  • Can anyone tell me why the following fails? It works fine on SQL Server Express 2005 but not on CE. The issue is the second part of the query.

    create table MyTable (id integer identity(1,1), name nChar(50))

    go

    set identity_insert MyTable on

    go

    insert into MyTable(id,name) values(2,'test')

    go

    Major Error 0x80040E14, Minor Error 25501

    > set identity_insert MyTable on

    There was an error parsing the query. [ Token line number = 1,Token line offset = 5,Token in error = identity_insert ]

    Major Error 0x80004005, Minor Error 25004

    > insert into MyTable(id,name) values(2,'test')

    The column cannot be modified. [ Column name = id ]

  • Are you using version 3.5? SET IDENTITY_INSERT support was introduced in version 3.5

  • In addition to what Martin said, If you are using CE 3.0 then use ALTER TABLE to SET identity.

    [font="Verdana"]--www.sqlvillage.com[/size][/font]

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply