sql server - Using UPDATE in stored procedure with optional parameters -


I have one such SP (using SQL Server):

  Optional process [Dbo]. [Sp_ClientNotes_update] @id Unique Identifier, @ Ordering Cadence = Faucet, @Novarchar (20) = Faucet, @ Content Text = Set Next On Setting Tull; Update tbl_ClientNotes SET command = @order, title = @ title, content = @ content WHERE id = @ id END  

If they are passed in SP then I just want to set the value I mean, that's not zero, can it be done?

It is suggested that the only way is using completely different questions with conditional, but for 3 optional parameters it will definitely be a nightmare!

Try it out.

  Optional work [dbo]. [Sp_ClientNotes_update] @id uniqueidentifier, @ordering smallint = NULL, @ title nvarchar (20) = null, @ text of content; start as null = nakota; Update tbl_ClientNotes SET command = ISNULL (@order, ordering), title = ISNULL (title, title), content = ISNULL (content, content) WHERE id = @ id END  

It may also be good to add additional sections for the WHERE section, if you use transaction copy, it will send another update to the customer, if all are zero, then to stop it for.

  WHERE id = @ id and (not @ordering or tap or title is not or does not have content @ content)  

Comments