February 11, 2014 at 11:11 am
Using [AdventureWorks2012] to perform insert which fails with error and I don't understand what to change to make insert work:
Msg 8101, Level 16, State 1, Line 1
An explicit value for the identity column in table 'AdventureWorks2012.Sales.SalesOrderDetail' can only be specified when a column list is used and IDENTITY_INSERT is ON.
--insert_on statement worked
set identity_insert [AdventureWorks2012].[Sales].[SalesOrderDetail] ON
GO
--this failed.
insert into [AdventureWorks2012].[Sales].[SalesOrderDetail]
values
(43665, 1, 'HkTest', 25, 715, 1, 25.00, 5.00, 25.00, 'B207C96D-D9E6-402B-8470-2CC176C42283', getdate());
February 11, 2014 at 11:42 am
You have to add the column list to the table you're inserting into.
insert into [AdventureWorks2012].[Sales].[SalesOrderDetail]( <Column list goes here>)
values(43665, 1, 'HkTest', 25, 715, 1, 25.00, 5.00, 25.00, 'B207C96D-D9E6-402B-8470-2CC176C42283', getdate());
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply