 Hey guys, welcome to SSUnitag, Sushil this side and today we are going to start a new playlist. So this is related to the Secus over real-time scenarios. So here the first scenario that we are going to discuss like how we can insert and delete in the same query without using the merge statement. So basically let's assume inside the store procedure we are having a table and we want delete the data on that table and at the same time we want to insert the data into the error lock table. So like how we can do that. So in a single query we just want to delete that and on that query we also want to insert the data into error lock table or we could say like how we can use the magic tables outside the triggers. So here we will see about these. So go to on the Secus over management studio and we'll see in the practical. So here as you can see we are having the first table that is user temp table and second that is error lock table. So first we just want to create these two tables. So we can directly execute the create statement and after that we want to insert the data on the table. So we can directly insert the data into the user temp table. Now we can check the data. So here we could see we are having five rows. So what is our requirement? Our requirement is we want to delete the data where the organization name is not equals to SS unity that we could see for ID three four and five. So we want to delete that data in this table and at the same time we want to insert that data into error lock table. So this could be used inside the store procedures where we might need to delete some data on the user table or any another table. And at the same time we want to insert the data into error lock tables. So here we can directly write the delete statement. So delete then from and after that we could see this user temp. So we can directly copy this and paste it here and let me call this as user temp. So that is UT. So we want to delete the data from this UT table that looks good. But we want to insert the data into the error lock table. So for that we have to use the output keyword after this UT and before that from then we could directly use the deleted that is the magic table. Then we could use the dot ID we can put comma then we could use the deleted dot the second that is name then put comma then deleted dot organization name. So we are having the first column that is ID second name and third is the organization name. The last one that is the error description. So we could say like the organization is not valid. And we want to insert that inside the error lock table. So we can directly use this statement. So this is a very straightforward like we just want to delete the data from this user temp table. And here we could also use the where organization name is not equals to SS Unitec. So we want to delete only that data. So this is a very straightforward query like delete from this UT table that is user temp where organization name is not equals to SS Unitec. In between UT and from we have to use the output keyword and after that we could use the magic tables. So here like we are going to delete the data so ID from the deleted table then name then organization name and last one the description of the error. So now we just want to execute this deleted statement. So once we execute then we could see three rows affected. Now I just want to write the select as tick from user temp table. So data should be deleted from this table and should be inserted into the error lock table. Now let me execute these two tables and we will check the output. So as you could see here in the first table the ID three four and five has been deleted and that is inserted inside the error lock table. And here error description is saying organization is not valid. So that we could use inside the store procedure in the real time. So here like we could also specify multiple deletes with the description of the error. So this we could use and here we could also see like how we can use the magic tables outside the triggers because here we don't have the trigger. We just want to delete the data. So I hope guys you have understand how we can insert and delete in the same query without using the magic statement. We'll see in the next video with one more real time scenario. 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. Thank you so much. See you in the next video.