tinyevil777
Registered User.
- Local time
- Today, 20:00
- Joined
- Dec 10, 2010
- Messages
- 137
Afternoon all.
I've got an interesting one for you...
I have a product table, which i want to update using either SQL query, store procedure, or the SSIS import routine.
ProductTbl
ProductCode XRef
ABC ABC123
XYZ XYZ123
MNO MNO123
I have an excel document, containing new cross references (xref) which i want to use to update the ProductTbl.
Excel document
ProductCode XRef
ABC ABC123
XYZ XXX999
MNO OOO111
RST RST321
Scenario 1: Where the product codes match, and the Xref's match, do nothing. This is because there is no change necessary. (Example ProductCode: ABC)
Scenario 2: Where the product codes match, and the Xref's are different, update the Xref field in ProductTbl using the data in the Excel Document. (Example ProductCode: XYZ & MNO)
Scenario 3: Where the product code in the Excel Document is not in the ProductTbl, append that record to the ProductTbl (Example ProductCode: RST)
I've rattled my brain thinking about how i can do this, a store procedure seems like the obvious choice, as it caters for the use of an 'if statement'. However... i've never written a store procedure, and wouldn't know where to start.
There may even be something to already caters for this, but to my knowledge there isn't, therefore i'd greatly appreciate someones input, suggestion or advice on this matter.
Thanks alot in advance!
Tom
I've got an interesting one for you...
I have a product table, which i want to update using either SQL query, store procedure, or the SSIS import routine.
ProductTbl
ProductCode XRef
ABC ABC123
XYZ XYZ123
MNO MNO123
I have an excel document, containing new cross references (xref) which i want to use to update the ProductTbl.
Excel document
ProductCode XRef
ABC ABC123
XYZ XXX999
MNO OOO111
RST RST321
Scenario 1: Where the product codes match, and the Xref's match, do nothing. This is because there is no change necessary. (Example ProductCode: ABC)
Scenario 2: Where the product codes match, and the Xref's are different, update the Xref field in ProductTbl using the data in the Excel Document. (Example ProductCode: XYZ & MNO)
Scenario 3: Where the product code in the Excel Document is not in the ProductTbl, append that record to the ProductTbl (Example ProductCode: RST)
I've rattled my brain thinking about how i can do this, a store procedure seems like the obvious choice, as it caters for the use of an 'if statement'. However... i've never written a store procedure, and wouldn't know where to start.
There may even be something to already caters for this, but to my knowledge there isn't, therefore i'd greatly appreciate someones input, suggestion or advice on this matter.
Thanks alot in advance!
Tom