?
Solved

update

Posted on 2013-05-30
1
Medium Priority
?
341 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
manbehindthecurtain earned 2000 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Suggested Courses

801 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