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)
 Update statment fails

Author  Topic 

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 15:25:18
I have an update statement that is running to update about 65000 records and it just keeps running without completing. Any ideas?

update address set ImportID = null where ImportID is not null

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-16 : 15:29:50
Why do you need the 'WHERE' clause if you just want to update everything to nulls..

Just
update address set ImportID = null
should do... no?
Go to Top of Page

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 15:38:19
Tried that still seems to just keep running with no end. Anything other ideas?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 15:40:14
Check for blocking via sp_who2.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 15:47:23
Used sp_who2 killed all processes that might be blocking me. Could it be an index issue. I seem to rememeber reading back that indexes could hurt update and insert performance.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 15:51:37
Well too many indexes could hurt you. How many do you have on that table? Do you have one on ImportID?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 15:56:36
I have 5 indexes on the table. This a very large table about 1.3 million records. I have two non-clustered/non-unique indexes on the AddressID and ImportID together. Could that be a problem? Looks like two of the same indexes.

Wierd thing is the message has a popup right away saying the 65000 rows have been effected, but then the query just keeps running. Any ideas why that is?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 15:59:50
That is definitely weird. Close the query window and try it again.

1.3 million rows in a table is tiny. Try supporting ones with billions!

Get rid of the duplicate index.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-16 : 16:03:11
Can you also check if there are there any triggers on this table too?
Go to Top of Page

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 16:18:44
Disabled the indexes still nothing. Sorry meant 1.3 million rows is large in relation to this database. I am going to try restarting sql server and maybe the query will magically work again.
Go to Top of Page

bcanonica
Starting Member

35 Posts

Posted - 2009-12-16 : 16:30:51
Great call vijay one of the triggers was causing the issue. Much thanks to both you and Tara for all your help with this issue.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-16 : 16:35:37
Np..You're welcome.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-16 : 16:47:00
Great call vijay!

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-16 : 16:52:57
Thanks Tara...Just one of those days I guess...
Go to Top of Page
   

- Advertisement -