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 |
|
ElFuego
Starting Member
1 Post |
Posted - 2011-11-21 : 16:40:19
|
| Hi All,I have SQL DB consisting of 3 columns (Tuple, LCE_ID and GIC_CODE) and i would like to create SQL test which will check this DB and in case a value of GIC_CODE is found repeated with different LCE_ID values it should generate an error with the tuple value.Example:Tuple 4 (LCE_ID 579) and tuple 128 (LCE_ID 512) have same GIC group "80H".Tuple 5 (LCE_ID 580) and tuple 129 (LCE_ID 513) have same GIC group "81H".so it should generate an error as follows:Test 1101 Error: duplicate GIC_CODE in tuples 4 and 128Test 1101 Error: duplicate GIC_CODE in tuples 5 and 129Initially i extracted the valid tuples as shown below and i need to run the test on this temp output (T_GIC).//GET valid tuple FROM R_GIC_CODESELECT D_LCE_ID , D_GIC_CODEFROM R_GIC_CODEWHERE D_LCE_ID != 65535AND raw_to_num(D_GIC_CODE) != 65535INTO temp T_GIC;Thanks in advance for your assistanceBR,ElFuego |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-11-22 : 00:58:42
|
| [code]SELECT t.*FROM R_GIC_CODE tINNER JOIN (SELECT D_GIC_CODE FROM R_GIC_CODE GROUP BY D_GIC_CODE HAVING COUNT(DISTINCT D_LCE_ID)>1 )t1ON t1.D_GIC_CODE = t.D_GIC_CODEORDER BY t.Tuple,t.LCE_ID [/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|