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
 Old Forums
 CLOSED - General SQL Server
 selective insert

Author  Topic 

shwetabrahme
Starting Member

4 Posts

Posted - 2006-03-04 : 14:03:45
i have a txt file containing lot of data..however i want bulk insert some of the rows in the database....

is it possible to do it using any particular insert query...if yes can anybody suggest me the kind of query to be written for the same

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-04 : 16:18:22
insert the whole file into a temporary staging table and insert desired rows from there.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-06 : 00:41:19
eg

Bulk insert to stagingtable

Insert into yourTable(columns)
Select columns from stagingtable
where <condition>

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

shallu1_gupta
Constraint Violating Yak Guru

394 Posts

Posted - 2006-03-06 : 01:50:34
use openrowset to query your text file
Insert into Table Name (columns)
select columns from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};
DefaultDir=C:\a.csv;','select * from
MyCsv.csv')
where <condition>
Go to Top of Page

shwetabrahme
Starting Member

4 Posts

Posted - 2006-03-06 : 11:38:43
hey thnx a lot all of u!!
Go to Top of Page
   

- Advertisement -