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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Bulk Inserts

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2005-02-23 : 11:33:06
Guys,

I have a scenario where in a table I ve nearly half a million rows(which ve been imported from text file).
I need to create a new column and insert values in it(these values are manipulated from existing columns).

As you would know first part can be done, but the second part of inserting values for the new columns against each
of the half million rows is a concern.

You would also update mite not be a plausible solution, since only one row can be updated each time.

Please suggest me any other methods by which this can be done.

Thanks

dsdeming

479 Posts

Posted - 2005-02-23 : 12:24:42
Try altering the table to add a computed column. I've done this with large input files and it's fast.

Dennis
Go to Top of Page

rockmoose
SQL Natt Alfen

3279 Posts

Posted - 2005-02-23 : 14:34:24
Add a computed column if it is truly a computed one (i.e., the value is derived from the other columns)

Otherwise just add the column and update the value. half mil rows is not a big issue.
Just make sure that you update all the rows in a batch (NOT row by row in cursor or loop)
We usually batch update 1-2 mil rows at a time for bigger tables(>3mil rows), takes 4-8 mins.(not very scientific numbers)

rockmoose
Go to Top of Page
   

- Advertisement -