Showing posts sorted by relevance for query bulk insert. Sort by date Show all posts
Showing posts sorted by relevance for query bulk insert. Sort by date Show all posts
Thursday, April 26, 2007

Bulk insert with dynamic primary key -SQL Server 2000/2005

You often need a bulk insert with dynamic primary key where you can define your keys without getting it from the .txt files or .csv files.here are the stored procedure to bulk insert country with dynamic primary key.first create temp.txt file in c drive with following data.AustraliaCanadaAmericaIndiathen create table with following fieldscountryid int 4countryname varchar(100)and assign name as tblCountryMasternow...
Share:
Thursday, March 1, 2007

Stored Procedure-Importing CSV Files into Table -SQL Server

Here is the Stored Procedure code for importing comma seperated CSV files to table.CREATE PROCEDURE [dbo].[sp_ImportScript]@filepath varchar(2000)ASBEGIN TRYdeclare @tmpsql varchar(3000)set @tmpsql='BULK INSERT table'set @tmpsql=@tmpsql + ' FROM ''' + @filepath + ''''set @tmpsql=@tmpsql + ' WITH (FIRSTROW=2,FIELDTERMINATOR ='set @tmpsql=@tmpsql + ''','''set @tmpsql=@tmpsql + ',ROWTERMINATOR ='set...
Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews