Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BULK INSERT questions
Message
De
14/01/2009 18:41:31
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
14/01/2009 17:52:06
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Import/Export
Versions des environnements
SQL Server:
SQL Server 2005
Divers
Thread ID:
01373782
Message ID:
01373812
Vues:
17
>I am using bulk insert to insert records from a flat pipe delimited file to a table. Here is the script I am using:
>
>
>BULK INSERT
>	MyTable
>FROM
>	'c:\MyFile.txt'
>WITH
>(
>	FIELDTERMINATOR = '|'
>	, ROWTERMINATOR = '|\n'
>	, FIRSTROW = 2
>)
>
>
>I have two questions:
>First, is there a way to avoid the rows being index based? Is there way to use the column header to determine what field the element belongs in, instead of just skipping the row like I am in the example?
>
>Second (and this might be related to the first question), is there a way to include an auto-incrementing PK field?

Mike,
I didn't understand your first question.
Second, auto inc PK is part of the table itself and thus would auto populated.

I don't know if it were you who asked a similar question recently, if not check SqlBulkCopy class. It is easier to use, much more flexible and IMHO as fast as bulk insert (or faster).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform