Re: how to create stored proc to read in flat file, parse it, and create records?

hkvats_1999_at_yahoo.com
Date: 06/25/04


Date: 25 Jun 2004 02:38:04 -0700

you can also use BULK INSERT

following is the example inserting from csv flat file to Order Details
SQL Server Table....
BULK INSERT Northwind.dbo.[Order Details]
   FROM 'f:\orders\lineitem.tbl'
   WITH
      (
         FIELDTERMINATOR = ',',
         ROWTERMINATOR = ',\n'
      )

regarding bcp.fmt....

you create your own fmt file for BCP Operation you need to specify
this BCP format file, while executing BCP command....

Regards
Hari Sharma
Sr. Consultant Databases....

"NotGiven" <noname@nonegiven.net> wrote in message news:<KCKxc.239$cP5.140@bignews6.bellsouth.net>...
> thanks! Where is bcp.fmt located?
>
>
> "Aaron W. West" <tallpeak@hotmail.NO.SPAM> wrote in message
> news:13mdndRDhbaf9Frd38DK-g@speakeasy.net...
> > look up BULK COPY, the version of BCP you can use from a stored procedure.
> >
> > You might run BCP the first time to generate an initial BCP.FMT file, then
> > edit that file as needed.
> >
> > ---
> >
> > "NotGiven" <noname@nonegiven.net> wrote in message
> > news:tkIxc.12080$LC3.9291@bignews2.bellsouth.net...
> > I am relatively new to sqlserver but I have done this in another database
> > without stored procs.
> >
> > I want to be able to:
> > - read in several flat files that contain 1000's of records with fixed
> > length delimited fields
> > - parse each field
> > - create sqlserver records with parsed records/fields
> >
> > I've written stored procs before but at a loss how to begin on this one.
> > Any help is much appreciated.
> >
> >
> >



Relevant Pages

  • Re: bcp native format file from DTS
    ... I called that views from bcp to load data in flat files as native ... After that while loading them in sql tables using Bulk Insert i am ... > And here is an example of manipulating the ExecuteProcess task. ...
    (microsoft.public.sqlserver.dts)
  • Re: Data Transfer
    ... Native mode is usually the cleanest and easiest to work ... BCP, BULK INSERT etc. ... >>>Andrew J. Kelly SQL MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: bcp native format file from DTS
    ... I called that views from bcp to load data in flat files as native ... After that while loading them in sql tables using Bulk Insert i am ... > And here is an example of manipulating the ExecuteProcess task. ...
    (microsoft.public.sqlserver.dts)
  • Re: BCP format file
    ... There is no way you can do this with BCP, ... use the bulk copy API and bulk from variables. ... Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx ... Books Online for SQL Server 2005 at ...
    (microsoft.public.sqlserver.tools)
  • Re: Data Transfer
    ... I'd go with native format, as long as the file produced is to be used by BCP, BULK INSERT etc. ... >>the data and log files before attempting an operation ...
    (microsoft.public.sqlserver.programming)

Loading