Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Updating 350 Million Records from other table taking too long

$
0
0

Hi,

I have a table1 with new column that needs to be populated from table 2. Table1 has 350 million records in it.

Below is the code i am using... But it takes too long even to update the 1 million

  DECLARE @BacthRecs int 
		SET @BacthRecs = 1000000
		WHILE @BacthRecs = 1000000 
		BEGIN
				UPDATE top ( 1000000 ) a
				SET a.NewColumn = isnull(t.Column1, 0.0000)
				FROM Table1 a with (NOLOCK) INNER JOIN Table2 t with (NOLOCK)
											on   a.Year = t.Year
											and a.ZipCodeKey = t.ZipCodeKey
				WHERE a.year = '2013' 
		SELECT  @BacthRecs = @@ROWCOUNT
		END

Is there is any other way to make it fast? Please let me know. Any help is appreciated.

Thanks,

Punia


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>