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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Store proecdure

Author  Topic 

mcbtiger
Starting Member

4 Posts

Posted - 2010-05-23 : 13:54:35
hello Expert

My problem is If/Else condition not work in store procedure
i create store procedure i just test If /Else condition it not work
if ClientAmount is greater then 500 it insert TotalAmount Add ClientAmount+10 and insert TotalAmount show 510 And if ClientAmount less then 500 it insert TotalAmount show 490 less show

i create table

Create table Profiles(Names varchar(25),ClientAmount int,TotalAmountint)
go
create proc Pro
as
if exists (select * from profiles where ClientAmount >= 500)
begin
update profiles
set Totalamount=ClientAmount+10
where Totalamount is Null
end
else
if exists(select * from profiles where ClientAmount <=500)
begin
update profiles
set totalamount=Client-10
where Totalamount is Null
end

Muhammadali

Sachin.Nand

2937 Posts

Posted - 2010-05-23 : 15:09:21
Maybe your table has records where client amount is less and more than 500.If thats the case then always the first update will be executed.

PBUH
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2010-05-23 : 15:57:30
So What you want when ClientAmount = 500?
Go to Top of Page
   

- Advertisement -