SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 why can it be only deleted this way?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

allan8964
Posting Yak Master

247 Posts

Posted - 04/06/2013 :  20:03:42  Show Profile  Reply with Quote
Hi there,

I try to delete something from a table with statement:

delte from Table where code is null

it won't work except statement like this:

delte from Table where code is null and ID = 1234

How can I check what causes this?

russell
Pyro-ma-ni-yak

USA
5071 Posts

Posted - 04/06/2013 :  21:48:24  Show Profile  Visit russell's Homepage  Reply with Quote
yes it will. you're doing something else wrong...what error are you getting?
Go to Top of Page

allan8964
Posting Yak Master

247 Posts

Posted - 04/06/2013 :  22:29:11  Show Profile  Reply with Quote
I don't have any error msg. Just hangs on, like frozon. I use sp_who2 to check, not found anything blocked.
Go to Top of Page

Jeff Moden
Aged Yak Warrior

USA
649 Posts

Posted - 04/07/2013 :  12:25:20  Show Profile  Reply with Quote
quote:
Originally posted by allan8964

I don't have any error msg. Just hangs on, like frozon. I use sp_who2 to check, not found anything blocked.



If the table is large, then it might appear to be frozen due to a full table scan. The criteria you added may have cause an INDEX SEEK which makes it run faster.

You might have to put an extra unique index on the table consisting of both the Code and the ID (in that order... the ID will make it unique and much faster as I assume that the ID is the PK).

--Jeff Moden
RBAR is pronounced "ree-bar" and is a "Modenism" for "Row By Agonizing Row".

First step towards the paradigm shift of writing Set Based code:
"Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

When writing schedules, keep the following in mind:
"If you want it real bad, that's the way you'll likely get it."
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000