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 : 02:55:59
|
| hi, How do i write a stored procedure that contains an update statement or statements to update a table, based on thee updated values. These values are sent from the business layer. Assume the table is Customer and it has fields CustNo, CustName and CustAddress. Typically i would write simple update statement that updates all fields even if i have update only one column. Assume in the business layer updates only CustName still i would sent custNom CustName and CustAddress to the stored procedure. If i write update statements up update columns individudally then i have to write three update statements. 1. fires only if CustName has been updated2. fired only if CustAddress has been updated3. fired only if custName and CustAddress have been updated. Therefore in my things will get complicated if the number of fields are more than 3....How do i write update statements in a stored procedure to meet my requirements?cheers |
|
|
kishore_pen
Starting Member
49 Posts |
Posted - 2009-08-27 : 02:59:46
|
| can you try for CASE statement in your update or write if condition then you can update the accordingly. |
 |
|
|
sqlontherun101
Starting Member
16 Posts |
Posted - 2009-08-27 : 03:03:24
|
quote: Originally posted by kishore_pen can you try for CASE statement in your update or write if condition then you can update the accordingly.
Could you give me a sample on writting case statement in SQL beuase this is the first time i'm doing some SQL programming? |
 |
|
|
|
|
|