Click here to Skip to main content
15,895,011 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i need to use bulk insert facility in sql server.i want to import data from a text file to a table
except the uniqueidentifier that i need to insert dynamically.....any solutions.
Posted
Updated 1-Jul-11 1:53am
v3

 
Share this answer
 
If your table is configured correctly, the unique identifier will automatically increment - all you have to do is add the rows.

As to your problem, I would do it this way (psuedo-code follows):

open file
create/open connection
create command object
while you have records
{
    set the cmd parameters with the data you have to insert for the current record
    SqlCommand.ExecuteNonScalar (I would also call a stored proc, but that's up to you)
}
close connection
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900