Common data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • balabaster
    Recognized Expert Contributor
    • Mar 2007
    • 798

    #1

    Common data

    How would I write a query to give me back the common piece of data that exists across multiple fields...

    I'll give a basic example...I've got a bunch of fields that were returned as the result of a regular expression - for instance, a bunch of postal codes. Obviously the commonality is the regular expression... they all matched.

    So how do I get the matching data itself from across these fields...

    T3A5N1
    T3A5N2
    T3A5N3
    T3A5N4
    T3A4N1

    The regular expression was actually "(?<=^|\W)( ?i:[A-Z]\d[A-Z]\s*\d[A-Z]\d)(?=\W|$)".
    As we can see, any validly formatted postal code would have been extracted from the string.

    Given that we have a list of all valid postal codes from our recordset, I now need to know any commonality between them on a more granular level than my expression handles.

    For instance, as a human, I can say that "T3A_N_" is the pattern of common data from the fields returned.

    How would I express this in T-SQL? Is it possible to express this as a T-SQL query? Or would I need to send the dataset to the CLR and do some comparison there?
Working...