Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sqlontherun101
Starting Member
16 Posts |
Posted - 2009-08-27 : 06:46:53
|
| Hi, I have modified my previoseu thread to this new thread:I need to create a procedure with one update statement that is capable of updating a table of three columns. where one column (CustNo) is auto increment. The table has three columns 1. CustNo2. CustCatName3. CustCatDescriptionTherefreo from the business layer, thsi table can be updated in following ways:1. update ONLY CustCatName column2. udpate ONLY custCatDescription column3. update both custCatName and CustCatDescriptionTherefore in common sense i have to create three update statenents in a Storeproceudre. But i need to create one update statement by check updates to other columns are avalable. If updates avlabel the inout paramter should have a value else NULL. I have written the followin sketch but i need some assitance in completing my procedure. OR if you have another way of doing this please let me know. ALTER PROCEDURE ProcUpdateCustomerCategories @PCustCatName AS NVARCHAR(100), @PCustCatDescr as NVARCHAR(MAX), @PCustCatNo AS INT ASBEGIN IF @PCustCatName IS NOT NULL --ADD THE PCustCatName to the update statement ELSE IF @PCustCatDescr IS NOT NULL -- Add the PCustCatAddress to the update statement update tblCustomerCategories SET <something here>where catNo = @PCustCatNo;ENDGOTY in advance |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2009-08-27 : 08:42:15
|
Try this..update tblCustomerCategories SET CustCatName = COALESCE(@PCustCatName,CustCatName),CustCatDescription = COALESCE(@PCustCatDescr,CustCatDescription)where catNo = @PCustCatNo |
 |
|
|
|
|
|