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

Help on Finding Records

$
0
0
I have a Table IMP in which data  is imported from text file ..

SID      State  ShortName
1001     VA      Nut
1001     VA      Com
1001     VA      EOW    
1001     VA      Plan
1001     VA      ECO
1001     VA      ABC
1001     VA      land
1001     VA      earth   
1001     VA      SEA
1001     VA      Air

like wise i have for many states and many Short names ...


>another Table EXClusiveID
BID  ShortName    EXID  State
5    NUT           211  VA   
5    NUT           212  VA
5    NUT           213  VA
6    Com           211  VA
6    Com           212  VA
6    Com           213  VA
211  Eow           5    VA
211  Eow           6    VA
211  Eow           7    VA
212  Eco           5    VA
212  Eco           6    VA
212  Eco           7    VA
213  land          5    VA
213  land          6    VA
213  land          7    VA

EXClusiveID table gives information about BID and what are the exclusive EXID should be submitted , meaning if one state VA submits BID 5 with short name "NUT"  they cannot submit with 211(Eow),212(Plan),213(Eco).

I have to check Shortnamecolumn in Table IMP .
Ex: If there is shortname NUT which is (BID=5) and EOW (BID=211)or 212 or 213  i should throw error (i have to insert the values in another table )
bottom line is if there is 5 it should not have 211 , 212 , 213 values in my Imp table and if there is 6 it should not have 211 , 212 , 213 , if 7 it should not have 211 , 212 , 213
if 211 it should not have 5,6,7 ...

can anyone help me in checking the values using function or cursor



Viewing all articles
Browse latest Browse all 23857

Trending Articles



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