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 |
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-03 : 06:09:53
|
| I have one table with 5 columnsexample:id fname lname dob address1 aaa bbb 01/02/2001 hhhh2 bbb ccc 02/05/2001 kkkklike thatnow i have one txt file which cosistsfname,lnameddd fffrrr tttttt sssslike thatcan i able to bulk upload this txt file into my table in sqlserver 2008?using BULKINSERT tblnameFROM 'c:\csvtest.txt'WITH(FIELDTERMINATOR = ',',ROWTERMINATOR = '\n')the above syntax? |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-03 : 07:01:35
|
| thanks man, it works finebut on extension to this, i haveone more doubtsample table:id fname lname ratingid remarks1 aaa bb 2 good2 bbb vv 1 vgood3 cccc cc 4 oklike thatThe ratingid is coming from Master tableratingid rating1 A +2 A3 B +4 Blike thatif u buld load from txt file meansthe .txt file will contain:1, aaa,bb,A,good2, bbb,vv,A+,vgood3, cccc,cc,B,okbut i want to store ratingid instead of Rating in my Tableis it possible? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-03 : 09:28:46
|
| Import the file to staging table. Update staging table value by matching with master table. Copy the staging table to your working tableMadhivananFailing to plan is Planning to fail |
 |
|
|
Arun.G
Yak Posting Veteran
81 Posts |
Posted - 2010-06-04 : 01:54:43
|
| i didnt get u properlycan u able to expalin with sample records? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-06-04 : 03:24:01
|
| 1 Create new table with five columns2 Bulk insert to that table3 Update nset col4=m.ratingidfrom new_table as n inner join Master_table as mon n.col4=m.rating4Insert into your_working_table(col_list)select col_list from new_tableMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|