Solved

update

Posted on 2013-05-30
1
333 Views
Last Modified: 2013-05-30
I am not sure how to write this update statement, depending on @feeoption.

create procedure  Updatefees
@id   int,
@amountpay    int,
@amount_customer  int,
@feeoption   varchar(6)

as

if @feeoption = 'both'
    update mytable  set payaccount = '0', set payclient = '0' where id =@id
if @feeoption = 'client'
    update mytable  set payaccount = @amountpay ', set payclient = '0'  where id =@id
if @feeoption = 'customer'
   update mytable set payaccount = @amountpay ', set payclient = @amount_customer   where id =@id
0
Comment
Question by:VBdotnet2005
1 Comment
 
LVL 1

Accepted Solution

by:
manbehindthecurtain earned 500 total points
ID: 39209599
create procedure  Updatefees
@id   int,
@amountpay    int,
@amount_customer  int,
@feeoption   varchar(6)

as

if @feeoption = 'both'
begin
    update mytable  set payaccount = '0',  payclient = '0' where id =@id
    end
if @feeoption = 'client'
begin
    update mytable  set payaccount = @amountpay ,  payclient = '0'  where id =@id
    end
if @feeoption = 'customer'
begin
   update mytable set payaccount = @amountpay ,  payclient = @amount_customer   where id =@id
   end
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now