need procedure for add the books counting.
example
total books =50;
now i need to take one book 1;
now it reduce from the total -1=49;
if i return the book the value must be add to the total as 50;
procedure in sql server2008
Need procedure for add the value in sql server2008.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Iftikar HussainRank #423 · 5.9K reputationPosted Aug 17, 2013, 11:30 PM EDT
Try like this
CREATE PROCEDURE usp_UpdateBookDetails
(
@BookId int,
@Type varchar(20)
)
AS
IF @Type='Issue'
BEGIN
UPDATE BookTable SET NoOfBook=NoOfBook-1 WHERE BookId=@BookId
END
ELSE
IF @Type='Return'
BEGIN
UPDATE BookTable SET NoOfBook=NoOfBook+1 WHERE BookId=@BookId
END
Regards,
Iftikar