syntax error table variable

前端 未结 1 1369
無奈伤痛
無奈伤痛 2020-12-21 08:47

This is the code:

declare @Ids table ( Id int identity(1,1));

SET IDENTITY_INSERT @Ids ON;

and I get:

Incorrect syn

相关标签:
1条回答
  • 2020-12-21 09:13

    You can't use SET IDENTITY_INSERT on table variables

    This works

    CREATE TABLE Ids ( Id int identity(1,1))
    SET IDENTITY_INSERT Ids ON
    

    and this

    CREATE TABLE #Ids ( Id int identity(1,1))
    SET IDENTITY_INSERT #Ids ON
    
    0 讨论(0)
提交回复
热议问题