Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2006-02-13 : 08:51:37
|
Mark writes "Hi,Currently, I use cursor to map the data we get monthly. I know cursor is slower. However, I am not that familar with other method. I was wondering if experts could help!Here is how I do it now:I import data into a staging table in SQL.When loading into the first table, let's say Table A, a value of one fields will be compared with the data in Table A, if it doesnt exist, insert and get the PK just inserted; if it does, dont insert and get the PK of that record.After Table A is ready, for the Table B, C..... While data has been importing, the PK value it got from the Table A will also be inserted.....Could experts show me an example how to do this? thank you very muchMark" |
|
mwjdavidson
Aged Yak Warrior
735 Posts |
Posted - 2006-02-13 : 16:26:17
|
Markquote: After Table A is ready, for the Table B, C..... While data has been importing, the PK value it got from the Table A will also be inserted.....
Based on what? How do you decide which row gets associated with which identity value? Whichever field(s) you use to make this decision could most likely be used to implement a set-based solution. Post some DDL (create table statements) for your staging and destination tables and some DML (insert statements) to populate the staging tables with some data.Mark |
 |
|
|
|
|
|
|