Need to Cross check for 5 x 5 column

  • Dear Experts,

    I really struggle with this

    I have one table with 6 columns

    Id , T1_flg,T2_flg,T3_flg,T4_flg,T5_flg

    1001 ,1 ,0 ,0 ,1 ,0

    1002 ,0 ,1 ,0 ,0 ,0

    I want to check with cross if already one slab is exits i wont allow to insert,

    If my insert values is

    1003 ,0,0,1,0,1 should allow to insert

    if my input is

    1003 ,1,0,0,0,0 shoul not allow, because the T1_flg, is already active with previous slab.. please help me to overcome this problem

  • I would change the design of the table:

    Unpivot the data, reduce it to have only values other than Zero and add a unique constraint on Flg_type.

    You'd basically have a table as follows

    ID Flg_type

    1001 T1

    1001 T4

    1002 T2

    With the constraint as mentioned you can add

    1003 T3

    1003 T5

    But not

    1003 T1



    Lutz
    A pessimist is an optimist with experience.

    How to get fast answers to your question[/url]
    How to post performance related questions[/url]
    Links for Tally Table [/url] , Cross Tabs [/url] and Dynamic Cross Tabs [/url], Delimited Split Function[/url]

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply