All I'm trying to do is declare a variable called @ReservationID, initialize it to a value from the Reservation table where certain conditions exist, and use that value as a parameter to insert a new Folio table entry. When I go to print my Folio table, the new table entry doesn't exist. I've checked and ran the SELECT statement, and it comes up with the correct value based on the conditions. Am I not initializing or passing the variable correctly? What am I missing here? Any help would be appreciated.
DECLARE @ReservationID smallint;
SET @ReservationID = (SELECT ReservationID FROM Reservation WHERE ReservationDate = CONVERT(varchar, GETDATE()) AND CreditCardID = 1)
SET IDENTITY_INSERT Folio OFF
INSERT INTO Folio (ReservationID, GuestID, RoomID, QuotedRate, CheckinDate, Nights, Status, Comments, DiscountID)
VALUES(@ReservationID, 500, 20, 35.50, '07/24/2016', 3, 'R', NULL, 1);
ReservationIDis IDENTITY column?