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

Reuired sql assistance in msql 2008

$
0
0

 Based on source1 & source2 data should be inserted / deleted in output tables. Initially these fields  -fieldcd, field6cd,field7cd in ouptut tables will be inserted thru this code. Additionally, user will have an option to update these (fieldcd,field6cd,field7cd ) values thru UI.

In tables  by dafault  table1output-fieldcd=2;table2output-field6cd=2;table3output-field7cd=2 values will be inserted.

field1 is common in 3 output tables.

Conditions - scenario1 - when table1output=2 - If New row added or deleted existing row in source1 or source 2.  - In this case, records should be inserted or delete in table2output and table3output when table1output-fieldcd=2. If any record is inserted or deleted in table2output corresponding values should be inserted or deleted in table3output

scenario2 - when table1output-fieldcd=3 - If New row added or deleted existing row in source1 or source 2.  - In this case, records should be inserted or delete in table2output and table3output when table1output-fieldcd=3 and table2output-field6cd=2 and table3output-field7cd=2 only.   If any record is inserted or deleted in table2output corresponding values should be inserted or deleted in table3output. If anyof the of the record  table3output-field7cd<>2 then that asosciated values should be deleted from table2output

source1

field1field2field3
124949
224949
324949
4249761
5313761
6313761
7313761
8313761
9313761
1031386
11251886
12251814
132113
142113
152113
162113
172113
181203
191203

source2

field9field3
1386349
1386449
1386549
13737761
13738761
13739761
13740761
13741761
13742761
1251086
1359586
1009314
104393
104403
104413
104423
104443
104453
104473

table1output

field1field2fieldcd
12492
23132
325181
42113
51201

table2output

field1field4field5field6cd
1149y
1249n
1349n
14761n
25761n
26761n
27761n
28761y
29761y
21086n
31186n
31214n
4133y
4143y
4153y
4163n
4173n
5183n
5193n

table3output

field1field7cdfield7field8
y113863
n213864
n313865
n413737
2   n513738
2  n613739
2  n713740
2  y813741
y913742
n1012510
n1113595
3  n1210093
4  n1310439
n1410440
4  y1510441
y1610442
4  n1710444
5  n1810445
n1910447




Viewing all articles
Browse latest Browse all 23857

Trending Articles



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