Results 1 to 4 of 4

Thread: Conditional Updates

Threaded View

  1. #1

    Thread Starter
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Resolved Conditional Updates

    In my stored procedure I have a large amount of data that can be updated. What I would like to do is not update anything that is passed into the stored procedure as NULL. How can I accomplish this?

    Basically I'm looking for something like this:
    Code:
    UPDATE [MySchema].[MyTable]
    	SET
    	IF (@MyField IS NOT NULL)
    	BEGIN
    		MyField  = @ MyField 
    	END
    	WHERE @UserID = UserID
    Last edited by Kasracer; Sep 27th, 2008 at 10:57 AM.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width