Jump to content


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.

Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.


Should I handle it in the SQL procedure or in the code?

  • Please log in to reply
No replies to this topic

#1 hispaladin


  • Members
  • 245 posts
  • Gender:Male
  • Location:Middle of a corn field
  • Local time:03:37 PM

Posted 25 May 2016 - 11:07 AM

I know my title is confusing but I couldn't think of a better one for my question.  So I have an application I am building that allows us to track projects and the associated tasks that is linked to a MS SQL database.  The question I have is that my tasks table has some columns that are FK and can be null, when my application sends the data to the database to be stored sometimes those columns are null and sometimes they are not.  The trouble is that the application doesn't want to send a null value, it wants to send 0 instead which causes errors on the SQL side as that is not a valid FK.  So would it be better to handle this in the code somehow or to handle it in the SQL procedure by testing the value of the parameter and assigning it to 'null' if the value is 0?  I know how to do it both ways I am just wandering which would be the better way.

BC AdBot (Login to Remove)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users