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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Need help in SQL Bulk Insert

Author  Topic 

reddaiah.u
Starting Member

1 Post

Posted - 2011-05-31 : 04:57:43
Hi Friends,

Could any one help me to insert data from the file which contains header , acutal data to be insert and footer

please find the file format below for your referance.

START-OF-FILE
RUNDATE=20110527
FIRMNAME=dl426512
DATEFORMAT=yyyymmdd
COMPRESS=yes
PROGRAMNAME=getdata
PROGRAMFLAG=one-shot
SECMASTER=yes
CLOSINGVALUES=yes
DERIVED=yes
START-OF-FIELDS
FX-RATE
END-OF-FIELDS
TIMESTARTED=Fri May 27 02:37:22 EDT 2011
START-OF-DATA
CME|993|1|
CHF|928|1|
LOR|658|1|
TEM|428|1|
SAE|158|1|
END-OF-DATA
TIMEFINISHED=Fri May 27 02:37:25 EDT 2011
END-OF-FILE

I need to insert the data which is present in between 'START-OF-DATA' and 'END-OF-DATA' Tags in the table.

Could any on help me on this,

Thanks in advance



Regards,
Reddaiah

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2011-05-31 : 06:08:23
Create a table with two columns, one identity column and one varchar(max), that act as a temporary storage for your import. Then bulk insert all rows to the varchar-column without separating out the actual columns. Then when you have the data in the table it will be much easier to manipulate the data in the way you want with regular sql statements...

- Lumbago
My blog-> http://thefirstsql.com/2011/02/07/regular-expressions-advanced-string-matching-and-new-split-function-sql-server-2008-r2/
Go to Top of Page
   

- Advertisement -