Sql trigger for updating one table from another

I am quite new to this whole posting stuff, but I am trying my best ... they usually check in at the same day though, so the Check In Date should be the same ... You did a fine job posting pretty much everything needed here.

The problem with posting sometimes really is that we are not working in the same environment / business logic .

And I can tell you, the ones entering data via asp-Forms in this case are Retards ...

I guess I need a Stored Procedure/Function to actually accomplish that:- On Insert of Customer Record pass NEWEST Check In Date and Insert into Room-Table Field Check In Date- When Rooms. Assuming you find a room you create a new row in Reservations with the Customer ID and the Room Num along with the dates of the reservation.

Occupied is marked as 'False', set the Check-Out-Date for all CU_ID with Customer. You now have a very clear view of all rooms at any given point in time. I can assure that if you try to maintain a status on the Room like your trigger you are in for a long battle. Here is a very basic rough sketch of what I would consider a better approach to maintaining the Occupied state of a room.create table My Customer( Customer ID int identity primary key, FName varchar(25), LName varchar(25))create table Reservations( Reservation ID int identity primary key, Customer ID int, Room ID int, Check In Date datetime, Depart Date datetime)create table My Rooms( Room Num int primary key, Num Beds int, Coffee Maker bit)Of course you would need to create foreign keys and such. It would certainly make the need for your trigger to go away. Cross Tabs and Pivots, Part 1 – Converting Rows to Columns Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs Understanding and Using APPLY (Part 1)Understanding and Using APPLY (Part 2) I think you are making this way too complicated by having denormalized information.

I created all the Columns and moved the existing data from the Accommodation-Bookings to the Customer Table.

Now I got left with this Requirement to autoupdate fields between the two remaining Tables 'Customer' and 'Rooms'.

Here's how to fix this: Start your free month on Linked In Learning, which now features 100% of courses.

Develop in-demand skills with access to thousands of expert-led courses on business, tech and creative topics.

I found a solution that is working on Database-side using Triggers actually ...

Tags: , ,