Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
update query in sql server with user session id
Devendra Kumar
Apr 14 2016 5:04 AM
368
Reply
hi friends please solve this query:
i am add product in cart
it insert.
and when update my quantity it update
but i want when add repeat product then it return value=3;
in this procedure
insert and update proper work ;
but repeat return value =3 not working
Set @count=(Select COUNT(1) from dbo.MyCart where SessionId=@SessionId and Product_Fkid=@Product_Fkid)
if
(@count=0)
begin
Insert
into dbo.MyCart(SessionId,Product_Fkid,Qty,size_Fkid)
values
(@SessionId,@Product_Fkid,@Qty,@size_Fkid)
Set
@ReturnValue=1
end
Set
@count=(
Select
COUNT(*)
from
dbo.Tbl_MyCart
where
Qty=@Qty
and
Product_Fkid=@Product_Fkid)
and
SessionId=@SessionId
if
(@count=1)
begin
Set
@ReturnValue=3
end
else
begin
update
dbo.Tbl_MyCart
Set
Qty=@Qty
where
SessionId=@SessionId
and
Product_Fkid=@Product_Fkid
Set
@ReturnValue=2
end
return
@ReturnValue
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
count product in sqlserver use PARTITION BY
Full Text Index