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 |
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-03-09 : 23:35:05
|
| Hi,Here is my scenario... I'm working in a project where the client will give us datas in the form of either csv or txt file(we are still not sure abt the file format yet, Their DB is Oracle). It will be a one single file and with a minimum of million records. I have to extract those datas from the file, and import only the related columns in my tables according to my db design. I have atleast 12 tables now.So my questions areCan I do this with DTS?If yes, how can import to different tables?What are the other options available?What could be the best source file format for this? (Txt,XML etc)This process will happen every month. The size of data might differ.Any thoughts?Thanks and Regards,Karunakaran |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-03-10 : 18:03:29
|
| Import all of the data into a staging table that matches the format of the csv file. Then use T-SQL to normalize the data into your 12 tables.Tara |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-03-10 : 23:16:23
|
| Thanks for the idea. I'll try with it and let you people know how it goes.Karunakaran |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-03-14 : 05:18:33
|
| Some more details..We have atleast 2 files(diff in structure) which needs to be imported to the database. I have to import these 2 files to the 12 tables in the database.As Tara said, I have imported the 2 tables to 2 temp tables. Now all I have to do is select the respective columns and import them to the 12 tables wherever neccessary. But now the client says, if certain conditions are not satisfied then I have to skip that record and process the next one...Essentially they are talking about processing and importing records one by one.Whats the best way I can do this?Any links to articles how to do this would be great full.Can I do this in DTS itself or should I go for something else?Karunakaran |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-03-14 : 07:21:13
|
| row by row processing is almost always a bad idea.could you do something like this:insert targettable(cola,colb,colc,,,)select col1,col2,col3,,, from stagetablewhere not(<certain conditions>)rockmoose |
 |
|
|
karuna
Aged Yak Warrior
582 Posts |
Posted - 2005-03-14 : 08:23:25
|
| I think posting the db structure might help to understand my problem. I'll post it soon. For starters, Here is my list of columns in the 2 staging tables:TempTable ORDBill To CustShip To CustVAR CustReseller CustEnd User CustEnd User Cust NoCust Major GeoOrder NoOrder DateYearQuarterMonthEnd User Cust No1Bookings Unit QtySale SKUSale SKU DescProduct FamilyProduct OfferingOS FamilyProduct Version NoRevenue TypeBookings Dollar AmtBkngs Txn Curr AmtTxn Currency CodeBookings Disc PctTempTable IBROrg IDCurrent Order Bill To CustCurrent Order Ship To CustEnd User CustEnd User Cust NoEnd User Cust Line 1 AddrEnd User Cust Line 2 AddrEnd User Cust Line 3 AddrEnd User Cust CityEnd User Cust Ctry NameEnd User Cust Postal CodeOriginal Order DateOriginal Order NoOriginal PO NoOriginal Ref NoCurrent Order DateCurrent Order NoCurrent PO NoOrder TypeCurrent Ref NoEnd User ContactEnd User Contact Email AddrEnd User Contact Phone NoLic QtySKUProd VersionSKU DescProd Family CodeProd Family DescProd Offering DescOSProd Pricing TierProd Install StatusProd Host IDProd Serial NoSvc Order NoSvc ProdSvc Txn Res Status CodeSvc Prod Item Start DateSvc Prod Item End DateSvc Txn Eff DateSvc Txn Exp DateSvc Txn Dur QtySvc Covered FlagUserTable CustomerContactCustomerID - End User Cust NoContactFName - End User ContactContactLName - This doesnt have a matching value in either of the temp tables and for now will be always null.ContactCity - End User Cust CityContactCountry - End User Cust Ctry NameContactPinCode - End User Cust Postal CodeEnd User Customer No has to match with the 2 temp tables and End User Contact should be distinctI tried an insert statement with select using distinct clause for End User Contact, but got some errors...Almost this how all the 12 tables need to be pushed datas from the temp tables...Karunakaran |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-03-15 : 08:34:18
|
| Show us the insert statement.This is probably just a matter of writing the correct SQL for loading each of the 12 tables.rockmoose |
 |
|
|
|
|
|
|
|