Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Newbie to SQL.  Running SQL 2005, have a table trying to delete some rows but anything with a NULL in the field will not delete.  Getting horrible error message...

Posted on 2006-06-01
5
Medium Priority
?
674 Views
Last Modified: 2008-01-09
other rows without NULL deleted just fine.  I know this is probably something simple and easy to do but my lack of SQL knowledge isn't helping much.  Can someone walk me through in newbie terms as much as possible on getting this going.  Thanks ahead.
0
Comment
Question by:33788
  • 2
  • 2
5 Comments
 
LVL 13

Expert Comment

by:MikeWalsh
ID: 16809111
Can you give us more information?

Show us the script. Tell us about the table.

What is the "horrible error message" youa re getting?
0
 
LVL 13

Expert Comment

by:Atlanta_Mike
ID: 16819983
Since I missed the class on mind reading, you'll definitely have to give us some information.

If you're trying to delete rows that have a null value in the constraining column... you need to

DELETE
FROM Table
WHERE ColumnName IS NULL

What is horrible??? To me horrible is ACCESS_VIOLATION_EXCEPTION. Or even worse Login Failed for user ... that would mean my pink slip is in my mailbox.

For future knowledge... post the script and post the rror message. Describe what the results are supposed to be. And we'll be able to help you fully... probably with overkill.
0
 

Author Comment

by:33788
ID: 16820231
Sorry all, I should of provided more details.  In MS SQL Server Managment Studio when right clicking to delete the rows with NULL values I get the message pop-up below.  ATL Mike how do you go about getting to what you suggested above.  Again I'm learning this as I go, hopefully with some more training shortly will get me up to speed.  If you don't mind explaining it in newbie terms I'm catching on but some stuff is quiet confusing.  Thanks ahead.

" No rows were deleted."  

"A problem occurred attempting to delete row # ."

"Error Source:  Microsoft .Visual.Studio.DataTools."

"Error Message:  The row value(s) updated or deleted either do not make the row unique or they alter multiple rows (2 rows)."

"Correct the errors and attempt to delete the row again or press ESC to cancel the change(s)."
0
 
LVL 13

Accepted Solution

by:
Atlanta_Mike earned 2000 total points
ID: 16820324
Hell... it looks like you don't have a primary key on the table... thats bad.

You need to open a new query window and do this...

DELETE
FROM Table
WHERE ColumnName IS NULL

Then add a primary key field with an identity column.

That shoudl fix you all up.
0
 

Author Comment

by:33788
ID: 16873605
Thanks, it worked.  
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question