TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Devendra Kumar
NA
517
246.2k
update query in sql server with user session id
Apr 14 2016 5:04 AM
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
Reply
Answers (
1
)
count product in sqlserver use PARTITION BY
Full Text Index