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

Insert Issue

$
0
0

Hi All ,

Below are the Sql Scripts

create table Product
(ProductID int Primary Key,
 Product_Name varchar(30))
 

  insert into product values(1'ABC');
  insert into product values (2,'ABC1');

  create table ProductName
  ( Product_Name varchar(30))
 
  insert into ProductName values('ABC');
  insert into ProductName values ('ABC1');

  create table ProductConfig
  (ConfigID int primary Key,
   ProductID int ,
   ProductConfigID varchar(30),
   Value varchar(40))


   insert into productConfig values (1,1,12,'Sample')
      insert into productConfig values (2,1,13,'Sample12')
      insert into productConfig values (3,1,12,'Sample')
      
   insert into productConfig values (4,2,12,'Sample')
      insert into productConfig values (5,2,13,'Sample12')
      insert into productConfig values (6,2,12,'Sample')

The Logic is the names that match in the ProductName and Product table  then the ProductID for those matching records

should be searched in the Product Config table  if those id's already exist a new record should be inserted into the

ProductConfig table with that ID as well as 2 hard coded values for the Column ProductConfigID and Value .

Hard Code values for those fields are 16 for ProductConfigID and Value - Sample45 .

The product config table configid is primary key not an identity column so the no should also increment when a new record is inserted into the table .

Kindly Help Very Urgent


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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