Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
maddyslayer
Yak Posting Veteran
57 Posts |
Posted - 2013-04-18 : 15:54:13
|
I have two tablesProductprod_cd prod_type prod_activep reg Yq reg Yr reg Ys reg Yt reg Yu reg Nv reg Nw irreg Yx reg YCustomers_id (Pkey) cus_id prod_cd prod_state1 1 p y2 1 q y3 1 v n4 1 w n5 2 s y6 2 p n7 2 q y8 3 p n9 4 q y10 5 v nWhat is the stored procedure to insert new records for a customer and that cus_id should have a record with each prod cd from the product table where prod_type = reg and prod_active = y and prod_state should be set to N?What is the stored procedure to loop through the existing customer (cus_id) records and check if they have all the prod_cds with prod_active = N or else add the prod_cds with prod_active = N that are not there and insert those records for that cus_id with prod_state set to N? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-19 : 02:32:07
|
where does the customerid come from? is it user input?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
maddyslayer
Yak Posting Veteran
57 Posts |
Posted - 2013-04-22 : 14:31:21
|
It is not user input, each customer has a unique id with different products |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-23 : 13:05:16
|
so what should be output for above sample data?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|