I tried to search for some days in several places but didn't succeed with this script.
I need to search for a String(NVarChar)
and a Number(Int)
in the same record, at all tables in a Database.
In the following example, I need to locate the Table and the Field where both criteria are present.
For example, find AAA string but only if a field with 990 number is present.
TBL_TEST
FIELD_A | FIELD_B | FIELD_C |
AAA | 124 | 12 |
BBB | 457 | 12 |
CCC | 347 | 12 |
AAA | 990 | 13 | <---
BBB | 387 | 13 |
CCC | 213 | 13 |
AAA | 888 | 14 |
BBB | 888 | 14 |
CCC | 888 | 14 |
****** I found this script at this great place but it only searches for string data and only one occurrence, but I need to find a String and a Number and only records where both records are available.
Let me try to explain me better, hope my English helps. Imagine a have a Database with 3 Tables (TBL1, TBL2 and TBL3). These tables have several columns, but in this example I will only place 3 columns per table.
TBL1
FIELD_A | FIELD_B | FIELD_C |
AAA | 124 | 132 |
BBB | 457 | 1E2 |
CCC | 347 | 1E2 |
AAA | KK0 | 13W |
BBB | 387 | 136 |
CCC | 213 | 133 |
AAA | 888 | 990 |<---
BBB | 888 | 144 |
CCC | 888 | 14 |
TBL2
FIELD_A | FIELD_B | FIELD_C |
AAA | ASD | 12 |
BBB | 3ED | 12 |
CCC | 32E | 12 |
AAA | 990 | 13 |<---
BBB | 123 | 13 |
CCC | 213 | 13 |
AAA | 445 | 14 |
BBB | 234 | 14 |
CCC | A23 | 14 |
TBL3
FIELD_A | FIELD_B | FIELD_C |
AAA | 124 | 132 |
BBB | 457 | 990 |
CCC | 347 | 1E2 |
AAA | KK0 | 13W |
BBB | 387 | 136 |
CCC | 213 | 133 |
AAA | 888 | 990 |
BBB | 888 | 144 |
990 | 888 | AAA |<---
The result of the script must be something like this.
TBL1
FIELD_A / FIELD_C
TBL2
FIELD_A / FIELD_B
TBL3
FIELD_A / FIELD_C
Hope to be clear enough. Thank you once more.