Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

An explicit value for the identity column in table 'productsales' can only be specified when a column list is used and IDENTITY_INSERT is ON.

$
0
0

--first table 

create table product([id] int identity(1,1) primary key,[name] nvarchar(50),[description] nvarchar(50))
insert into product values('tv','52 inches '),('laptops','16 inches '),('desktop','32 inches ')
select * from product

--2nd table

create table productsales (id int  primary key identity, unitprice int,quantitysold int)
SET IDENTITY_INSERT Productsales ON
insert into productsales values(3,450,5),(2,250,7),(3,600,4),(3,222,8)
select * from productsales
SET IDENTITY_INSERT Productsales OFF


HERE WHEN I AM  INSERTING VALUES FOR 2 ND TABLE I AM FACING ERROR

MY REQUIREMENT IS TO GIVE EXPLIT VALUES AND I HAD GIVEN SAME VALUES  IN ID COLUMN OF PRODUCTSALES BUT IT SHOULD ACCEPT


jitendra


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>