开发者

Problem in Inserting Datas in SQL Serve 2005

I created a talbe in SQL SERVER 2005 with Identity column. When i tried to insert the values to the table i'm getting error message and the values are not getting inserted.

Please find my table structure

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]

*Error Message*

An explicit value for the identity column in table 'SHSReporting.dbo.Sales' can only be specified when a column list is used and IDENTITY_INSERT is ON开发者_开发知识库

Kindly help to solve this problem

Thanks in Advance

  • Ranga


That's because when you are inserting data into your table, you are specifying a value for [SalesID]

Which is already autogenerated. Remove the value for SalesID and don't list it as one of your columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜