February 18, 2016 at 4:47 am
Hi All
I have two tables t1 & t2 which contains the same records. t1 is for bank1 & t2 is for bank2
i.e t1
accno name balance
001000 a 5555
t2
accno name balance
001000 b 6000
I have to insert both table records in file t3. What i want to find is which account number is from wich bank
file t3 will be created same as that of t1/t2 columns. We cannot use extra columns in file.
February 18, 2016 at 4:59 am
You can't fit a square peg into a round hole. If you don't want to add and extra column to t3, you'll have to resort to unsatisfactory methods such as adding something to the account name or number that identifies the bank.
John
February 18, 2016 at 5:10 am
Thanks John π
If we prefix the LHS bit with a β1β or any other numeral, then the users will then always have to key loads of zeroes and they may get grumpy about it. what you say ?
February 18, 2016 at 5:27 am
Grumpiness will be the least of your worries. It will be more difficult to validate entries, and you're breaking the rules of normalisation by forcing two attributes into one column. Why can't you just add another column to the third table?
John
February 18, 2016 at 5:46 am
John Mitchell-245523 (2/18/2016)
Why can't you just add another column to the third table?John
Exactly what I was thinking.
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
February 18, 2016 at 6:04 am
Nikku (2/18/2016)
Hi AllI have two tables t1 & t2 which contains the same records. t1 is for bank1 & t2 is for bank2
i.e t1
accno name balance
001000 a 5555
t2
accno name balance
001000 b 6000
I have to insert both table records in file t3. What i want to find is which account number is from wich bank
file t3 will be created same as that of t1/t2 columns. We cannot use extra columns in file.
Then create another table t4 which has account no and bank.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 22, 2016 at 12:04 am
Thanks Guys π
February 23, 2016 at 1:55 pm
ChrisM@Work (2/18/2016)
Nikku (2/18/2016)
Hi AllI have two tables t1 & t2 which contains the same records. t1 is for bank1 & t2 is for bank2
i.e t1
accno name balance
001000 a 5555
t2
accno name balance
001000 b 6000
I have to insert both table records in file t3. What i want to find is which account number is from wich bank
file t3 will be created same as that of t1/t2 columns. We cannot use extra columns in file.
Then create another table t4 which has account no and bank.
The problem here is that account numbers from the banks can collide (be the same).
----------------------------------------------------
February 23, 2016 at 3:13 pm
Please identify the banks you're doing this for so we can make sure that none of us will be affected by this. π
--Jeff Moden
Change is inevitable... Change for the better is not.
February 23, 2016 at 4:26 pm
Jeff Moden (2/23/2016)
Please identify the banks you're doing this for so we can make sure that none of us will be affected by this. π
+1 to that! π
February 24, 2016 at 2:17 am
MMartin1 (2/23/2016)
ChrisM@Work (2/18/2016)
Nikku (2/18/2016)
Hi AllI have two tables t1 & t2 which contains the same records. t1 is for bank1 & t2 is for bank2
i.e t1
accno name balance
001000 a 5555
t2
accno name balance
001000 b 6000
I have to insert both table records in file t3. What i want to find is which account number is from wich bank
file t3 will be created same as that of t1/t2 columns. We cannot use extra columns in file.
Then create another table t4 which has account no and bank.
The problem here is that account numbers from the banks can collide (be the same).
Yup - I'm working with bank data right now. Hence another table with account no and bank.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
February 24, 2016 at 6:10 am
Nikku,
On a less facetious note, The other are correct, in a straight file format (CSV, EDI, flat file) or another table you would not be able to identify the bank without either adding another column which you say is not possible, or contatenating the bank ID to the account number, thereby effectively doing the same thing and causing additional processing further down the line.
You could however identify the bank if you use XML
<BANK>
... whatever bank details you need in here
<ACCOUNTS>
<ACCOUNT>
<NUMBER>000106</NUMBER>
<NAME>A</NAME>
<BALANCE>5500</BALANCE>
</ACCOUNT>
<ACCOUNT>
<NUMBER>000107</NUMBER>
<NAME>K</NAME>
<BALANCE>4200</BALANCE>
</ACCOUNT>
</ACCOUNTS>
</BANK>
XML is easily read by computers and still readable by humans; you can provide DTD or DSX format rules
It does lead to quite large files though
You could also use JSON, although that notation is not supported by SQL out of the box so you would have to write your own
But in general I would challenge the assumption that you can't modify the columsn because whoever is going to read the data will have the same problems as you are creating the file/table
February 24, 2016 at 8:22 am
I definitely wouldn't use XML for anything even close to this. Also, computers don't "easily" read XML. There are programs that make it easy for Developers to incorporate it but it's pretty brutal behind the scenes all the way around. If you do a deep dive on it in SQL Server, it actually builds a temporary "Edge Table" in memory, which contains the XML as an "Adjacency List" and all the problems associated with such a structure. From what I understand, XML "indexes" are actually a "columnar normalization" of the XML data. I say cut out the middle man and don't use it for data transmittal or storage.
I view JSON as "only" being half as bad but half as bad is still a whole lot.
--Jeff Moden
Change is inevitable... Change for the better is not.
February 24, 2016 at 8:46 am
Jeff Moden (2/24/2016)
I definitely wouldn't use XML for anything even close to this. Also, computers don't "easily" read XML. There are programs that make it easy for Developers to incorporate it but it's pretty brutal behind the scenes all the way around. If you do a deep dive on it in SQL Server, it actually builds a temporary "Edge Table" in memory, which contains the XML as an "Adjacency List" and all the problems associated with such a structure. From what I understand, XML "indexes" are actually a "columnar normalization" of the XML data. I say cut out the middle man and don't use it for data transmittal or storage.I view JSON as "only" being half as bad but half as bad is still a whole lot.
Hmmm, sounds like the basis for an XML article, Jeff. I know how much you like it :w00t:
The absence of evidence is not evidence of absence.
Martin Rees
You can lead a horse to water, but a pencil must be lead.
Stan Laurel
February 24, 2016 at 10:46 am
Bump, Set, Spike!
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply