If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Question about best method to update optional fields.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-14-10, 05:57
MrRalphMan MrRalphMan is offline
Registered User
 
Join Date: Jul 2007
Posts: 50
Question Question about best method to update optional fields.

I think I know the best way for this, but I thought I would throw this up here. Over the last couple of years I have been tasked with developing/supporting the database for our Incident Management Application.

Now I came into this with minimal experience and have been learning all the time, it doesn't help that this isn't my primary role (yet).

When I designed the database it requires an audit trail to pick up changes, to this end the update query reads the record from the database, puts the variables into a set of before variables and then updates the worklog table with before and after details and then does a big update onto the main table.

We have a new app being developed and it is a lot smaller and doesn't need such detailed auditing. Now what method is better.

1)

Make all Input params for fields to update default to null.
If these fields are not null, then make a separate update.

This means no read for the DB and a few update commands (1 to 10ish).

2)
Same method as above. Read in all fields, update any where the param is not null and make one update at the end.

I am leaning toward number 1, but wondered if there was a best practise for this or if thee is an even neater way to do this.

Many Thanks,

Paul.
Reply With Quote
Reply

Tags
ms sql, question, update query

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On