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
247.7k
insert update query in sql server
May 3 2016 7:29 AM
hi any buddy help please
i have one sp in which i will insert and update up product like this:
Create
PROCEDURE
[dbo].[Sp_AddToMyCart]
@SessionId
varchar
(500),
@Product_Fkid
int
,
@size_Fkid
int
,
@Qty int
AS
Declare
@count int,@ReturnValue int
BEGIN
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
else
begin
update
dbo.MyCart
Set
Qty=@Qty
where
SessionId=@SessionId and Product_Fkid=@Product_Fkid
Set
@ReturnValue=2
end
return
@ReturnValue
END
insert update work properly but i face a problem when
i want insert same product then it return this product already add in your cart
Reply
Answers (
2
)
explain about stored procedure
Non clustered index