Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

iterate through a table

Status
Not open for further replies.

junkmail

Programmer
Jan 7, 2001
134
US
I have a table "a" with a list of files names of data that I want to bulk insert into table "b". My question is what is the simplest way to do this.

Sample data in table a

path(column name),flag(column name)
c:\work\data1.txt,false
c:\work\data2.txt,false

Now I want to iterate through table "a" and use the bulk insert command using the "path" column to bulk insert the data into table "b". I also want to change the "false" flag to "true" to denote that the file has already been imported. I seem to be having a problem with the looping through the table to get the next row to do the bulk insert.
 
The simplest way is like this:

Code:
Insert Into b(Path,Flag)
Select Path, 1
From   a

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
twitter
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top