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 |
dhani
Posting Yak Master
132 Posts |
Posted - 2008-11-05 : 17:19:34
|
Hello Allin my source file i have data as horizontal (not like regular file)exampleAccountNo: 00234543AccountName: KickserCity: ChicagoAccountNo: 00234543AccountName: AnnisCity: SeatleAccountNo: 12234456AccountName: pargenezzerCity: NYC............AccountNo: 12233477AccountName: PILIPCity: Edisoncan any one give me some idea how can i load this file to the sql server tableThanks in advanceasin |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-11-06 : 03:06:58
|
[code]create table test_data(data varchar(1000),value varchar(1000))BULK INSERT test_dataFROM 'file path'WITH ( FIELDTERMINATOR =':', ROWTERMINATOR ='\n' )alter table test_Data add id int identity(1,1)Insert into actual_table(AccountNo,AccountName,City)select t1.value as AccountNo, t2.value as AccountName, t3.value as City from(select id,value from test_Datawhere id%3=1) as t1inner join (select id,value from test_Datawhere id%3=2) as t2 on t1.id+1=t2.idinner join(select id,value from test_Datawhere id%3=0) as t3 on t1.id+2=t3.idselect * from actual_table[/code]MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|