 Hey guys, welcome to SSUnitag, so stay on this side and this is part 2 of SQL Server real-time scenarios. So today we are going to see how we can insert the data into the main table and at the same time we want to load the data into the audit tables. And for that we will be using the single query. And second we will be going to also see how we can use the magic tables outside the triggers. In the previous video we have seen how we can use the magic tables for deleting the data and inserting that data into the lock table. Here we are going to insert the data into the main table and at the same time we are going to load the data into audit table. So how we can write the query for achieving this output? So go to on the sequence of management studio where we will see in the practical. So here basically I have already written this script so it will save our time. So first as you can see this is our source table and it is having id name and organization name. Second table is user temp table. So this will be our main table. So first we want to load the data from this source table to this user temp table and at the same time we want to load the data into user temp audit table. So let me try to execute this query for creating the tables. So tables has been created successfully. Now we want to insert some data on the source table. So we can execute this insert statement. So now five rows has been affected. So five rows should be inserted into our table. So we can check that by writing the select a stick from our source table. Now we can execute this. Here we are having these five rows. Now here our requirement is we want to load the data from the source table to the user temp table. So for that we could write our insert statement that is very straightforward like insert into user temp table. So it is simply going to select the data from the source table and loading that data into user temp table. But at the same time we want to load the data into user temp audit table. So for that here in between insert and select we need to use the output keyword. And after output keyword we could use the inserted or deleted table. So here like we are going to insert the data. So here we could use the inserted table. So inserted dot id put comma then again from inserted table dot name again put comma then inserted dot or name. And we want to load these values into our user temp audit table. So this is our table. So this is very simple query. So first of all here like we want to load the data into user temp table from this source table. After that in between like we are going to use this output keyword. So after output keyword we could use the medic tables. So here like we are going to insert the data. So inserted table should be available over here. So in the inserted we are going to get the id name and organization name. And we want to insert these values into this user temp audit table. Now let me try to execute this and here five rows affected. Now we can select the tables and check the values. So select a stick from user temp table and select a stick from user temp audit table. Now let me execute these two queries. So here as we can see we are having the same values like five rows in the first table and five rows in the second table. So this is very straightforward query and I am going to put this query into the description of this video. So if you want then you can copy this and do the practice on your own. Thank you so much for watching this video. If you like this video please subscribe our channel to get many more videos. Don't forget to press the bell icon to get the notification of our newly uploaded videos. See you in the next video.