0
我使用Identity列在SQL SERVER 2005中創建了一個talbe。當我試圖將值插入到表中時,我收到錯誤消息並且值未插入。SQL Server 2005中插入數據的問題
請找我的表結構
CREATE TABLE [dbo].[Sales](
[SalesID] [int] IDENTITY(1,1) NOT NULL,
[Year] [smallint] NOT NULL,
[Month] [tinyint] NOT NULL,
[TradeStartDate] [date] NULL,
[TradeEndDate] [date] NULL,
[Notes] [varchar](200) NULL,
[UpdateDate] [datetime] NOT NULL,
[UpdateBy] [varchar](50) NOT NULL,
CONSTRAINT [PK_Sales] PRIMARY KEY CLUSTERED
(
[SalesID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
* 錯誤消息 *
只能指定表 'SHSReporting.dbo.Sales' 的標識列的顯式值當使用列列表且IDENTITY_INSERT爲ON時
請幫助解決此問題
由於提前
- 朗高
要麼,或者如果OP出於某種原因實際上具有SalesId的唯一值,則在插入之前設置IDENTITY_INSERT dbo.Sales ON,然後SET IDENTITY_INSERT dbo.Sales OFF之後 – StuartLC