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 |
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2010-09-29 : 06:13:26
|
Good day, i need help please.I have a table in which i'm updateing 1million records from a table that contains 16million records is still updateing afer 3hrs (sql2005)My join is on the same table with a different type, no lock & the server is running fineMy where and on clause is in the exactly same order as my clustered index (Type,Period,Item,Customer,Depot)Update V_Main Set V_Main.IF_Advertising=coalesce(Q1.IF_Advertising,0)From dbo.Temp_IForecast_Data V_Main ( NOLOCK )left join dbo.Temp_IForecast_Data Q1( NOLOCK ) on Q1.IF_Type='COST_NETVAL_CALC'and q1.IF_Period=V_Main.IF_Periodand q1.IF_Item=V_Main.IF_Itemand Q1.IF_Customer=V_Main.IF_Customerand Q1.IF_Depot=V_Main.IF_DepotWhere V_Main.IF_Type='COST_BASE'Please help |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-09-29 : 06:37:26
|
Can't seem to find anything wrong with the query other than the NOLOCK in an update statement which is HORRIBLE!- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2010-09-29 : 06:44:10
|
Thanks for helpingshould i remove the No Lock even when i'm join on the same table? |
 |
|
ismailc
Constraint Violating Yak Guru
290 Posts |
Posted - 2010-09-29 : 07:07:30
|
Thank You very much, It works nicely - did not know that (Nolock) on Update was not good.I also removed the Left to an Inner join.Thanks |
 |
|
Lumbago
Norsk Yak Master
3271 Posts |
Posted - 2010-09-29 : 07:17:58
|
If you don't know what the NOLOCK hint does then you should stop using it at once. It can cause severe problems and even corruption in your database if you're not using it right. I suggest you search this forum for NOLOCK and see what you find...- LumbagoMy blog (yes, I have a blog now! just not that much content yet) -> www.thefirstsql.com |
 |
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-09-29 : 08:40:29
|
quote: Originally posted by Lumbago If you don't know what the NOLOCK hint does then you should stop using it at once. It can cause severe problems and even corruption in your database if you're not using it right. I suggest you search this forum for NOLOCK and see what you find...
Hint -- it won't be pretty.Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
 |
|
|
|
|
|
|