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 2005 Forums
 Transact-SQL (2005)
 Need Help in Query

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-02-05 : 05:40:00
I have 2 tables. First table cantain 115 columns and 25 million records. second table contains 78 columns and 30 million records
Both tables have two common columns.
I have written update query to update all columns of first table when data match.. The problem is Query is running more than 5 hrs. How long it will run. Will it runing correctly?

Update t2 Set
t2.THAI = t1.THAI,t2.VIET = t1.VIET,t2.POLY = t1.POLY,t2.HAWA = t1.HAWA,t2.SAMO = t1.SAMO.............t1.col115 = t1.col115
FROM CountryOrigin As t2
INNER JOIN Asian_Final AS t1 ON t1.Zipcode = t2.Zipcode AND t1.Zip4 = t2.Zip4



G. Satish

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-02-05 : 05:42:03
The query will be faster if both ZipCode and Zip4 is properly indexed.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-05 : 06:11:10
quote:
Originally posted by satish.gorijala

I have 2 tables. First table cantain 115 columns and 25 million records. second table contains 78 columns and 30 million records
Both tables have two common columns.
I have written update query to update all columns of first table when data match.. The problem is Query is running more than 5 hrs. How long it will run. Will it runing correctly?

Update t2 Set
t2.THAI = t1.THAI,t2.VIET = t1.VIET,t2.POLY = t1.POLY,t2.HAWA = t1.HAWA,t2.SAMO = t1.SAMO.............t1.col115 = t1.col115
FROM CountryOrigin As t2
INNER JOIN Asian_Final AS t1 ON t1.Zipcode = t2.Zipcode AND t1.Zip4 = t2.Zip4



G. Satish


u cannot update asian_final t1 table
Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-02-05 : 06:26:02
When i am typing by mistake i typed t1.col115 = t1.col115, but it is t2.col115=t1.col115. I am updating the countryorigin table here.


quote:
Originally posted by bklr

quote:
Originally posted by satish.gorijala

I have 2 tables. First table cantain 115 columns and 25 million records. second table contains 78 columns and 30 million records
Both tables have two common columns.
I have written update query to update all columns of first table when data match.. The problem is Query is running more than 5 hrs. How long it will run. Will it runing correctly?

Update t2 Set
t2.THAI = t1.THAI,t2.VIET = t1.VIET,t2.POLY = t1.POLY,t2.HAWA = t1.HAWA,t2.SAMO = t1.SAMO.............t1.col115 = t1.col115
FROM CountryOrigin As t2
INNER JOIN Asian_Final AS t1 ON t1.Zipcode = t2.Zipcode AND t1.Zip4 = t2.Zip4



G. Satish


u cannot update asian_final t1 table



G. Satish
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-05 : 06:42:59
k fine satish enjoy...
Go to Top of Page
   

- Advertisement -