Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
| Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old October 4th, 2005, 11:52 AM
Registered User
 
Join Date: Aug 2005
Location: Chennai, Tamil Nadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Deleting NULL record in a table

How to delete a NULL record in a Sql table?



  #2 (permalink)  
Old October 4th, 2005, 12:14 PM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

delete from SomeTable where SomeField is null


http://sqlservercode.blogspot.com/
  #3 (permalink)  
Old October 4th, 2005, 12:27 PM
Registered User
 
Join Date: Aug 2005
Location: Chennai, Tamil Nadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Actually what is problem is I am having two or three null records in my table. If I give a sql query in my program its resulting null record first. So remaining records are not resulting and I am getting error message like:

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlTypes.SqlNullValueException: Data is Null. This method or property cannot be called on Null values.

How can I resolve this issue??


  #4 (permalink)  
Old October 4th, 2005, 12:30 PM
Authorized User
 
Join Date: Sep 2005
Location: , , .
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You don't want records with NULL values coming back to the frontend?

change your SQL to select * from SomeTable where SomeField is not null

http://sqlservercode.blogspot.com/
  #5 (permalink)  
Old October 4th, 2005, 12:49 PM
Registered User
 
Join Date: Aug 2005
Location: Chennai, Tamil Nadu, India.
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you very much SqlMenace. I tried to handle the null exception through coding and delete a null records from the table. But it didnt worked out. Finally your query workedout. Thank you

  #6 (permalink)  
Old October 4th, 2005, 04:58 PM
Friend of Wrox
 
Join Date: Aug 2004
Location: Orange County, CA, USA.
Posts: 385
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Also you may want to think about replacing the null value with a '' or empty value. Assuming you have valuable and important data in the rows that have a null in one field. I suggest you look into using the isnull function and replace the fields null value with something else to allow you to return those particular rows rather than simply ignoring the whole row because one field has a null value which is what the use of "is not null" syntax will do.



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems deleting a record donrafeal Access VBA 0 January 18th, 2007 06:19 PM
Problems In Deleting Record nkrust ASP.NET 1.0 and 1.1 Professional 2 January 12th, 2007 11:52 PM
Deleting All Record In A Table McDiddy Access VBA 3 January 10th, 2007 09:20 AM
Deleting A Record sirmilt BOOK: Beginning Visual Basic 2005 Databases ISBN: 978-0-7645-8894-5 1 July 31st, 2006 07:12 PM
deleting a record from a linked table??? tico31pl Classic ASP Basics 0 May 18th, 2006 09:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.