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.
Author |
Topic |
Indsqlbeginner
Starting Member
21 Posts |
Posted - 2014-09-29 : 03:28:32
|
Team,The update statement is taking very long time to execute. so we have been told to tweak the query. i'd request your help.Script is belowUpdate set column1 = '00000' from tbl1 awhere not exists (select id from tbl2 b where a.objid=b.objid) and a.column1 <> '00000' |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2014-09-29 : 04:03:26
|
I don't understand the query you have posted.It is updating column1, which has the value as '00000' to the value of '00000' again. What is the purpose of this query?Harsh Athalyehttp://in.linkedin.com/in/harshathalye/ |
|
|
Indsqlbeginner
Starting Member
21 Posts |
Posted - 2014-09-29 : 04:41:41
|
quote: Originally posted by harsh_athalye I don't understand the query you have posted.It is updating column1, which has the value as '00000' to the value of '00000' again. What is the purpose of this query?Harsh Athalyehttp://in.linkedin.com/in/harshathalye/
Sorry. Now I have updated script accordingly now.Note : Column1 <> '00000'can you kindly help now. |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2014-09-29 : 05:15:29
|
You may try converting not exists to left join:update t1set column1 = '00000'from tbl1 t1 left join tbl2 t2 on t1.objid = t2.objidwhere t2.objid is null and t1.column1 <> '00000' Also, you may need to check if any covering index is present on tbl1.Harsh Athalyehttp://in.linkedin.com/in/harshathalye/ |
|
|
|
|
|