September 6, 2005 at 1:25 pm
This is one row from an excel spreadsheet. I want the first 5 items in the row to go to table 1 and the last two items to go to table2
Dare ID | Type | Brand | Model | Serial | Vendor | OuR PO |
1135 | PC | Acer | 7500 | 29057773122653749AK | ABC | 6009253 |
September 6, 2005 at 1:54 pm
You just need two insert statements
insert into Table1 (fld1,fld2,fld3,fld4,fld5)
select DareID, Type, Brand, Model, Serial from XLSheet
--XLSheet is View wrapping a linked server access
insert into Table2 (fld1,fld2)
select Vendor, OuRPO from XLSheet -- same as above
You probably want to link the two but I leave that to you because no enough info was provided
Cheers
* Noel
September 6, 2005 at 2:10 pm
So if I have a large amount of data can I use BCP or DTS? linked is correct.
September 6, 2005 at 2:14 pm
Can't you simply import in a temp table, then insert/select in 2 batches.
September 6, 2005 at 2:14 pm
BCP only works with csv of fixed length text files
DTS can use XL Sheets directly
Or
You can create a Linked server or use Openrowset to access the file directly from SQL
* Noel
September 6, 2005 at 2:16 pm
Too many ways to skin the cat here .
September 6, 2005 at 2:26 pm
That is great everyone... thanks for the help
September 6, 2005 at 4:37 pm
Don't forget about OPENQUERY. It will help you access XLS sheets as normal tables or views without downloading it into temp tables.
Don't forget to add $ in the end of sheet name.
You can find complete reference for OPENQUERY in BOL with examples particulary for XLS files.
_____________
Code for TallyGenerator
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply