Update query - stored proc.

Results 1 to 2 of 2

Thread: Update query - stored proc.

  1. #1
    Join Date
    Dec 1969

    Default Update query - stored proc.

    Here is a sample...<BR><BR><BR>CREATE PROCEDURE update_sb<BR> @Transaction_ID int,<BR> @Time_Last_Updated smalldatetime = NULL,<BR> @cl_ID varchar(10) = NULL,<BR>....and so on.....and then i SET the values.<BR><BR><BR>How to declare cl_ID as OPTIONAL? because it defaults to NULL and its not a required param to update, hence it loses it original value upon update(obviously since it takes NULL value).<BR><BR>Thanks<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: Update query - stored proc.

    CREATE PROCEDURE update_sb<BR>@Transaction_ID int,<BR>@cl_ID varchar(10) = NULL,<BR><BR>AS <BR><BR>INSERT INTO yourTable (transaction_ID,cl_ID) VALUES (@transaction_ID, ISNULL(@cl_ID,cl_ID)<BR><BR>The ISNULL function checks if an value is NULL, if so it replaces it by the second value, in this example by the original value from the table

Posting Permissions

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