After update trigger Part 44

  Рет қаралды 333,869

kudvenkat

kudvenkat

Күн бұрын

Пікірлер: 144
@kavithasaphal
@kavithasaphal 7 жыл бұрын
Again and again I am telling..u r a born teacher...Hats off u for ur effort sir..finally understood..thank u so much.. gd bless u..
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 7 жыл бұрын
Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful. I have organised all the Dot Net & SQL Server videos in to playlists, which could be useful to you kzbin.infoplaylists?view=1&sort=dd If you need DVDs or to download all the videos for offline viewing please visit www.pragimtech.com/kudvenkat_dvd.aspx Slides and Text Version of the videos can be found on my blog csharp-video-tutorials.blogspot.com Tips to effectively use my youtube channel. kzbin.info/www/bejne/r2ibYYCtnb5qZtU If you want to receive email alerts, when new videos are uploaded, please subscribe to my youtube channel. kzbin.info If you like these videos, please click on the THUMBS UP button below the video. May I ask you for a favor. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them. Good Luck Venkat
@awaisbutt9012
@awaisbutt9012 7 жыл бұрын
Its more then useful. Its an asset
@sarahaaalmhtara5987
@sarahaaalmhtara5987 4 жыл бұрын
@@Csharp-video-tutorialsBlogspot looking to buy all the videos and everything you have for like 170$ right? since i be working on big project to get a certificate of programming engineer i needed your videos to help me me remembering all the stuff i learned i been looking through many books and pdfs nothing help more then your videos thanks for them i might buy everything very soon its very helpful and saves a lot of time searching for resources to learn i just click on the video and just learn i don't have to worry if its all the resources i need or i missed something out or i cant find that and that i just want to click and learn everything without worrying about anything else thank you *i have a question does the DVD version comes with one disc Blu-ray or anything or is it like many DVDs ? and not on one DVD only thanks*
@mithamazumdar8794
@mithamazumdar8794 4 жыл бұрын
@@Csharp-video-tutorialsBlogspot nice👍
@vishakhabinani6856
@vishakhabinani6856 Жыл бұрын
10 years since the playlist but still helping so many students!! Love and respect to you sir!!
@anuragvashishtha6660
@anuragvashishtha6660 12 жыл бұрын
Understanding the concept of an Update Trigger was never easy. The way you have built the foundation of this topic by explaining the significance of "inserted" and "deleted" tables "inside the scope of the Trigger" is a Master Stroke. I have said this before and I am compelled to say it one more time that you know the Science of Logic Implementation and the art of Teaching. Thanks a ton for these awesome video series.
@micbarpia
@micbarpia 4 жыл бұрын
You are the reason that normal schools should be changed for online schools with people like You ! really... MY HERO!
@seetamer
@seetamer 11 жыл бұрын
Man, you deserve Heaven & I wish it for you :-)
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Hi Ravi, you are absolutely right. The temp tables get automatically dropped after the stored proc has completed execution. That is the default behaviour. However, I personally feel, it's a good coding practice to explicitly drop the temp tables, than to leave them for the sql server to drop. This makes your code more readable, and may free up the memory that the temp table is holding onto, early in the process than waiting until the stored procedure is completed. Hope this answers your question
@rezoanhasib8394
@rezoanhasib8394 7 жыл бұрын
The code looks complicated, many would have made it so while explaining but you didn't. Cuz you a legend! Hats off dude.
@Thrudv
@Thrudv 7 жыл бұрын
I have a test tomorrow and I'm watching your videos. You explain everything really good so thank you very much!
@shubhenduinfotech5992
@shubhenduinfotech5992 2 жыл бұрын
You are born teacher just A mighty gift for all the beginar developer thank you sir
@nys8260
@nys8260 4 жыл бұрын
Thank You Mr Venkat, The best teacher over the world
@Akshayyam
@Akshayyam Жыл бұрын
This video was posted 10 years ago . I AM watching it in 2023 . in 2012 i dint knew anything about sql and all. Thankyou.
@Djabsey1
@Djabsey1 11 жыл бұрын
Venkat.. You have a unique gift of explaining complicated material so it is very easy to understand. I thank you for helping me pass my 70-461 Exam!
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Hi Tam, I have included the link to my blog in the description of this video, which contains the code you are looking for. Hope you will find it useful.
@devarakondasankararao3802
@devarakondasankararao3802 6 ай бұрын
Easy way of understanding about triggers .Thank You Venkat Sir.
@epuriraghavendra3847
@epuriraghavendra3847 6 жыл бұрын
I think no one else can explain as simple as you , you are an exceptional one sir, thanks a lot :)
@KaranShah-u8w
@KaranShah-u8w Жыл бұрын
Superb videos! I have finally been able to understand triggers! thank you so much Sir
@javielitostanley7040
@javielitostanley7040 8 жыл бұрын
Hey Bro!! Thank for you helpful Video!! You've already saved my life and added me a great knowing to my SQL's Skills!! Sincerity Thank you!! :D
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 8 жыл бұрын
Thank you very much for taking time to give feedback. This means a lot. I am very glad you found the videos useful. I have organised all the Dot Net & SQL Server videos in to playlists, which could be useful to you kzbin.infoplaylists?view=1&sort=dd If you need DVDs or to download all the videos for offline viewing please visit www.pragimtech.com/kudvenkat_dvd.aspx Slides and Text Version of the videos can be found on my blog csharp-video-tutorials.blogspot.com Tips to effectively use my youtube channel. kzbin.info/www/bejne/r2ibYYCtnb5qZtU If you want to receive email alerts, when new videos are uploaded, please subscribe to my youtube channel. kzbin.info If you like these videos, please click on the THUMBS UP button below the video. May I ask you for a favor. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them. Good Luck Venkat
@hridayaannuncio3583
@hridayaannuncio3583 6 жыл бұрын
Superb videos! I have finally been able to understand triggers! thank you so much
@danushkamalinga8487
@danushkamalinga8487 3 жыл бұрын
The best teacher ever.
@krzysztofs8535
@krzysztofs8535 8 жыл бұрын
Bravo! These videos are very useful. Very long syntax, then longest code from the beginning of the course.
@priyankathakare2760
@priyankathakare2760 3 жыл бұрын
Very informative video..Thanks a lot from all the learners..Keep it up. 👍
@Chetan.Kothari
@Chetan.Kothari 5 жыл бұрын
Thank you so much...God bless you!!! Your videos help us to learn concept deeper and clearly.
@avinashniture6841
@avinashniture6841 3 жыл бұрын
God bless you sir. Excellent teaching
@MsShanmathi
@MsShanmathi 5 жыл бұрын
Thank you so much. Your videos are very useful and its clearly explained
@JP-td8gt
@JP-td8gt 5 жыл бұрын
2:50 My question is on this part, "Select * from deleted & Select * from inserted". Are those tables you created before the video OR are those table names a default choice for the trigger update (you mentioned them as special tables). What I'm trying to understand and I can't at the moment, is, how do those two tables work/interact with the rest of the SQL script?...thank you in advance. After testing myself it makes sense now, I just had to try it for the first time. Looks like I am also a hands on learner. Thank you so much for the time you take to do this for us. God Bless you and your family.
@daalwada
@daalwada 5 жыл бұрын
When you create a trigger for 'after trigger' to insert a data you have to write 'select * from inserted', and when you create an 'after trigger' to delete a record, you have to write 'select * from delete'. This internally creates a copy of actual table in which you have inserted your records. When you execute a trigger, the data from actual table is fetched and the results are affected in inserted or deleted (virtually created tables) tables.
@pavithravvenu5817
@pavithravvenu5817 3 жыл бұрын
No words to say..hats off!!!!!
@sairamkandgule3365
@sairamkandgule3365 3 жыл бұрын
Hi, 1:14, part 42 of the video series is view limitations. not triggers. BTW, you're an awesome teacher.
@prosperg186
@prosperg186 5 жыл бұрын
Excellent video as usual. Very well done.
@slobodantajisic2762
@slobodantajisic2762 Жыл бұрын
Hm. What if I don't change anything in the update statement? I will enter garbage text in the tblEmployeeAudit.
@Csharp-video-tutorialsBlogspot
@Csharp-video-tutorialsBlogspot 11 жыл бұрын
Hi Ravi, To receive email alerts, when new videos are uploaded, please subscribe to my youtube channel. May I ask you for a favour. I want these tutorials to be helpful for as many people as possible. Please share the link with your friends and family who you think would also benefit from them. If you like these videos, please click on the THUMBS UP button below the video.
@madhuputtapaga426
@madhuputtapaga426 Жыл бұрын
u r extremely super explaining sir
@daliladali1268
@daliladali1268 7 жыл бұрын
you are my favorite teacher,thanks a lot
@sweetysharma2621
@sweetysharma2621 3 жыл бұрын
Very interesting example ❤️
@MixTapeYT1
@MixTapeYT1 7 жыл бұрын
For everyone, try using 1.25 speed, it's understandable and you have better concentration
@MuhammadUsman-yi5cw
@MuhammadUsman-yi5cw 4 жыл бұрын
Listening at 1.75 x would be much better
@reynaldoduazojr5681
@reynaldoduazojr5681 6 жыл бұрын
This is very helpful, i thank you very much for your effort sir, thumbs up (y) !
@rogercheng7564
@rogercheng7564 5 жыл бұрын
This is so helpful as always!
@anubhagupta5408
@anubhagupta5408 4 жыл бұрын
Amazing explaination. Thank you
@xavierdupont5772
@xavierdupont5772 6 жыл бұрын
I think that this trigger example is among the most horrendous SQL code that may exist on this plane. Very good for illustrating how triggers work. But as bad as it could be when it comes to putting that stuff in production.
@stephennguyen8052
@stephennguyen8052 8 жыл бұрын
Quick question. I'm following through the video (started from vid 1, thank you!) and I assumed you created tblEmployeeAudit with the ID column as int, NOT NULL, IDENTITY(1,1), PRIMARY KEY because you're not supplying the ID in your trigger. However, after I created your update,insert, and delete trigger (from the last video), say if I add a record into tblEmployee (maybe ID of the new record being added to tblEmployee = 9) and since the tblEmployeeAudit is empty with IDENTITY(1,1), SQL Server will attempt to add ID = 9 to tblAudit. This then generates an error "An explicit value for the identity column in table 'tblAudit' can only be specified when a column list is used and IDENTITY_INSERT is ON." , the same error that you discussed much earlier on when you first mentioned IDENTITY(1,1), how we have to set it off to explicitly add the ID = 9 to tblEmployeeAudit. It's not adding ID as 1 in tblEmployeeAudit How do you get past this, right now I'm completely stuck here even though I understand all the concepts you presented?
@stephennguyen8052
@stephennguyen8052 8 жыл бұрын
I figured it out, thanks kudvenkat
@justina7508
@justina7508 8 жыл бұрын
'Hi guys, I like to ask questions, then after figuring out the answer I don't post the solution for others to use.'
@stephennguyen8052
@stephennguyen8052 8 жыл бұрын
I didn't think anyone else would run into the same issue~
@mahebunissask6051
@mahebunissask6051 8 жыл бұрын
Stephen Nguyen I am also worrying with after trigger (update)querry.---unable to update a row in tblemployeeaudit table.. tblemployee table perfectly updating the required row..and tblemployeeaudit table not showing the --- id= 8 name updated.--..... update operation not working with audit table.. please tell me.. how u accessed..
@rahultiwari7744
@rahultiwari7744 8 жыл бұрын
Ak Number sir , what a way to Teach
@hariz6154
@hariz6154 4 жыл бұрын
Hi Sir, I tried to follow query in this video and it's going well if i updated just one column, but it's going to infnite loop if I try to update mulitples column. Example update tblemployee set departmentid = 3 where id in (2,3,4) any suggestion ? thank you.
@robbinshee
@robbinshee 11 жыл бұрын
You are a life saver !!!!
@pradeepdhamija569
@pradeepdhamija569 5 жыл бұрын
Dear Venkat: I created this trigger using different names so that I can understand it better intentionally. My code does not match but does work if I just use [ delete from #TempTable ] instead of {xx} below, this means loop never happens, but I get error while copiling at: {delete from #TempTable WEHRE EmpId = @Id}. If I select * from #TempTable right before the above statement, Then I can see the EmpId is there. Some how I get compilation error as below telling me that EmpId is invalid column name when I park my mouse on it. "Msg 102, Level 15, State 1, Procedure tr_AuditorEmployee_Update, Line 42 [Batch Start Line 10] Incorrect syntax near 'WEHRE'.." here is my code if you want to look at it. ALTER TRIGGER tr_AuditorEmployee_Update ON tEmployee FOR UPDATE AS BEGIN DECLARE @Id int DECLARE @Name varchar(20) DECLARE @Salary Int DECLARE @Gender varchar(20) DECLARE @DeptId int DECLARE @NewEmpId int DECLARE @NewName varchar(20) DECLARE @NewSalary Int DECLARE @NewGender varchar(20) DECLARE @NewDeptId int DECLARE @AuditString varchar(2000) SELECT * INTO #TempTable FROM inserted WHILE (EXISTS(SELECT EmpId From #TempTable)) BEGIN SET @AuditString = '' --New SELECT TOP 1 @Id = EmpId, @NewName = Name, @NewSalary = Salary, @NewGender = Gender, @NewDeptId = DeptId FROM #TempTable -- Old SELECT @Name = Name, @Salary = Salary, @Gender = Gender, @DeptId = DeptId FROM deleted WHERE EmpId = @Id SET @AuditString = 'Upadtes: ID:' + CAST(@Id AS nvarchar(20)) + ' ' --SELECT @Name AS OONE, @NewName AS TWOO If (@Name@NewName) Set @AuditString = @AuditString + @Name + ' Updated to: ' + @NewName + ' ~' If (@Salary@NewSalary) Set @AuditString = @AuditString + CAST( @Salary as nvarchar(20)) + ' Updated to: ' + CAST( @NewSalary as nvarchar(20)) + ' ~' If (@Gender@NewGender) Set @AuditString = @AuditString + @Gender + ' Updated to: ' + @NewGender + ' ~' If (@DeptId@NewDeptId) Set @AuditString = @AuditString + CAST( @DeptId as nvarchar(20)) + ' Updated to: ' + CAST( @NewDeptId as nvarchar(20)) + ' ~' INSERT INTO tEmployeeAudit VALUES(@EmpId, @AuditString, Getdate()) --SELECT *, 'TempTable' FROM #TempTable delete from #TempTable WEHRE EmpId = @Id END END I can't figure out what I cant use "WHERE EmpId = @Id" at the delete statement to continue the loop? Any one who can help will be appreciated. Thanks I am so happy by going through this series. I can not thank you enough.
@jutt_da_shugal2705
@jutt_da_shugal2705 7 жыл бұрын
I am trying hard but it give me an error Conversion failed when converting the nvarchar value 'new member id=7date isApr 4 2017 12:22AM' to data type int.
@devi07461
@devi07461 11 жыл бұрын
hi venkat, i am getting this "Column name or number of supplied values does not match table definition." ? while creating the trigger
@utkristpandey6641
@utkristpandey6641 4 жыл бұрын
Same problem, it didn't take id value Automatically that's why..
@davidz878
@davidz878 6 жыл бұрын
Why did salary increase when you changed gender from female to male at 3:30?
@hrvooje
@hrvooje 2 жыл бұрын
Why not use inserted table for while loop? Doesn'tt it contain multiple rows?
@bornofdata
@bornofdata 4 жыл бұрын
Before I try this hands-on, in situations where you have multiple records changing, if ID in (1,3,5) was used instead of ID = 4 will the TempTable get the IDs sequentially? is that why you used Top 1? Another question is the TempTable you used, it was not created before it was used in your query, can you insert in a temporary table that has not been created before the time of use, or is TempTable a system temporary table?
@markotomic7976
@markotomic7976 4 жыл бұрын
Should we join inserted table and the table we use to get data from ?
@mohanprabhu3091
@mohanprabhu3091 6 жыл бұрын
can we make as a previous coloum nd present coloum ....and what is the query for that my HR is asking me to do like that
@RaviYadav-ox3ks
@RaviYadav-ox3ks 11 жыл бұрын
hello sir, in this video you delete temp table, but i have learned that any of the temporary table created by trigger deleted automatically when proc execution completed , so is it required to delete it explicitly , please explain.
@prudhvik5603
@prudhvik5603 2 жыл бұрын
when we are using top 1 from temptable isnt that will be the same row we are always selecting?
@prudhvik5603
@prudhvik5603 2 жыл бұрын
okay got it. we are deleting that row at the end
@JP-td8gt
@JP-td8gt 5 жыл бұрын
Will this work if you are updating multiple records at a time? Say you have 50 columns, and I need to apply a last_modified date to my final table field; should any one column be updated with new value. Is that possible with current SQL presented, using Select Top 1 inside your trigger?
@kingnaveen5985
@kingnaveen5985 6 жыл бұрын
hello sir,in this video,your mention slide-42(DML Trriger),but actualy slide-42 is (View limitations concept).
@sajateacher
@sajateacher 9 жыл бұрын
Having problems with the triggers on this video and previous. Says that column names don't match or "Invalid Column name". Have checked and re-checked my code to make sure it matches with that on your blog. Are my settings wrong in MSSMS or do I need to go into the Config Manager or something else?
@SuperGojeto
@SuperGojeto 9 жыл бұрын
+Ryan Blais copy paste the error and code here then someone can guess what's the error.
@devenmhatre727
@devenmhatre727 8 жыл бұрын
Msg 213, Level 16, State 1, Procedure tr_tblEmployee1_forDelete, Line 9 Column name or number of supplied values does not match table definition. the error is shown at place where we concat the string to display it on the AuditData table
@larabsteve3350
@larabsteve3350 8 жыл бұрын
I think u made mistake on insert into tblemployeeAudit. this table takes only two value.
@sisaysarke588
@sisaysarke588 8 жыл бұрын
Thank you for bringing the technology so close to us and make it as easy as possible for people like me to understand it. I have one question though, Is there any way to obtain the scripts in a text form? thank you again.
@yareddz1124
@yareddz1124 8 жыл бұрын
csharp-video-tutorials.blogspot.com If you go to the link above, you can access all slide with the script.
@nandhinibaskaran7578
@nandhinibaskaran7578 3 жыл бұрын
for inserted why we are using a separate temp table. is there any purpose for this
@pramodmaurya6610
@pramodmaurya6610 6 жыл бұрын
Thanks for your knowledge sharing..
@gaureesha9840
@gaureesha9840 9 жыл бұрын
Can we directly use inserted table in the while condition? Why do we need the temporary table?
@deboadeyemi
@deboadeyemi 6 жыл бұрын
I was thinking the same thing. Maybe because you have to delete each row at the end of the trigger to prevent infinite loop. It may not be best practice or impossible to delete rows in inserted since it's a automatically produced record.
@nys8260
@nys8260 4 жыл бұрын
you can't remove rows from inserted table
@shanshanli7849
@shanshanli7849 10 жыл бұрын
Hi Venkat, I am thinking whether we could put the 'insert into tblEmployeeAudit values(@AuditString)' line within each if case analysis. That way if someone is trying to update multiple column values ( say name, gender AND salary) at one shot, the audit table can catch everything instead of the last value stored in the variable @AuditString. Please let me know if I miss anything. Btw you have been very helpful on my way learning SQL. Very concise and informative tutorials. Thanks a lot;-)
@mdmohshinctg
@mdmohshinctg 3 жыл бұрын
sir, how get/insert end user id/name into audit table using Update trigger when i using c#
@sheogorathmadgod3447
@sheogorathmadgod3447 7 жыл бұрын
i have a question....i don't understand why we use "delete from #temptable where id=@id". as far as i know, the while loop will let us insert single record on its first cycle and on the next cycle the cursor will move to next record.which will be insert to audit table.so at each cycle of while loop a record from #temptable will be added to audit table.And at the end the cursor of while will reach on an empty record hence giving 0 to while condition. but if at the end of while loop you delete the #temptable,how the while loop is suppose to re-enter another record.,at next cycle the while loop will not find #temptable.anyway your query is right and the while goes to infinite loop if not use this delete statement
@sheogorathmadgod3447
@sheogorathmadgod3447 7 жыл бұрын
oops sorry.... you are deleting only an id.every cycle..and there is no shifting to another record....
@josephregallis3394
@josephregallis3394 7 жыл бұрын
I wish you would have told me to change AuditData column size to nvarchar(1000) in the tblEmployeeAudit table. I kept getting errors and the AuditData string kept getting cut off. I finally saw where I had to change the column size from 70 characters to 1000. No more errors after that.
@shahbazalam4565
@shahbazalam4565 6 жыл бұрын
Wow...I am a fan
@SathishKumar-gs4er
@SathishKumar-gs4er 8 жыл бұрын
Hello Sir, I have one table with the field of Slno,Period,Total and 100 rows...now i want to make a calculation (Pivot) like Slno,Period,Total(sum of month wise) in second table...Please let me know how to do this...
@zooniesheikh3134
@zooniesheikh3134 2 жыл бұрын
just amazing.
@VF7RM
@VF7RM 8 жыл бұрын
I didn't get where the #TempTable come from....Was it previously created? Or it gets created with the statement inside the trigger?
@LiamFoot
@LiamFoot 8 жыл бұрын
He is creating it inside the trigger. He makes it because the inserted table changes when the trigger inserts a new record into the audit table, so he first saves a copy of the inserted table into #TempTable to save the original data.
@VF7RM
@VF7RM 8 жыл бұрын
+Liam2349 yes, I think I got it later. My doubt was when did he created the table, but now I think I understand that a temporary table can be created right with that statement
@Mayankg303
@Mayankg303 8 жыл бұрын
s name suggests #Temtable is mean to be provide a way to temporary storage of the data, so that we can get the values under it and use it during our query execution. I Would suggest you should read much abt it, so that you can get clear idea about it. Also read difference between #TempTable and ##TempTable
@DodgerDude74
@DodgerDude74 6 жыл бұрын
created on the fly if you haven't already explicitly declared it
@dunai2012
@dunai2012 5 жыл бұрын
One case that you may have ve forgotten: when any column variable value is NULL. You can't compare NULL values using or = although this is not the point on which your lecture focused .
@mohammedalkhafaf4229
@mohammedalkhafaf4229 6 жыл бұрын
it is very useful thanks
@vinayakshukla2455
@vinayakshukla2455 3 жыл бұрын
please may you tell why loop become infinite loop if i not delete id from #temptable
@Felixantony84
@Felixantony84 10 жыл бұрын
I have one doubt. If we update a table, will it call the update trigger... Because, this trigger is update event triggered one. Then how can we identify whether this triggering occurred at update or Delete event???
@jutt_da_shugal2705
@jutt_da_shugal2705 7 жыл бұрын
Which data type use in Audit column....
@semrithiro9386
@semrithiro9386 6 жыл бұрын
Where will deleted row go when we delete it from deleted table?
@neetusinha1
@neetusinha1 4 жыл бұрын
my update and insert command is executed like 'Employee with Id = 4 changed and New Employee with Id = 6 is added', It's not showing whole Employee's details, I used same query. Please answer me. Thanks!
@hostname47
@hostname47 6 жыл бұрын
Thanks a lot sir, my problem is that i understand the logic and all statements and how it work but for exemple if i don't watch this video i will forgot some logic statement ! anyone can give me some advices to master the logic in my brain
@momen153
@momen153 10 жыл бұрын
Mr Venkat, what about this message after insert trigger "cannot insert explicit value for identity column in Audit table when identity_insert is set to off.
@SuperGojeto
@SuperGojeto 9 жыл бұрын
+‫عمار رصرص‬‎ that means you should not insert id values in id column, that will be done automatically.
@momen153
@momen153 9 жыл бұрын
thank you very much
@SuperGojeto
@SuperGojeto 9 жыл бұрын
عمار رصرص your welcome :)
@Hemant_S_Bohra
@Hemant_S_Bohra 7 жыл бұрын
Error in Update Trigger Msg 245, Level 16, State 1, Procedure tr_tblEmp_forUpdate, Line 36 [Batch Start Line 47] Conversion failed when converting the nvarchar value 'Emp with Id = 3changedName from GauravtoNidhiGender from MtoFSalary from ' to data type int.
@jade101ism
@jade101ism 8 жыл бұрын
you left out the is deleted section of the code :(
@stutitehri993
@stutitehri993 10 жыл бұрын
great videos
@jyothikrishna2588
@jyothikrishna2588 11 жыл бұрын
Surampudi Tpdevi ..I think you didn set the Id column as identity column thats why you get this error...
@tejaswininandam6359
@tejaswininandam6359 2 жыл бұрын
Hi Venkat, Thanks for your great videos and effort in doing such a great work. My question is while creating a trigger I got an error like infinite while loop, after resolved it is working fine as it was. But auditdata table id has changed, it is showing after loop numbering, as I mentioned id as an identity column. Is there any way to get back to the serial number? The ids are like this 4 5 6 7 8 655556 655557 655558 Thanks in advance.
@piyasidey2117
@piyasidey2117 4 жыл бұрын
What is the difference between part 43 and part 44..I can't found any.
@piyasidey2117
@piyasidey2117 4 жыл бұрын
Thank you sir.
@Chetan.Kothari
@Chetan.Kothari 5 жыл бұрын
Thank you!!!
@Hemant_S_Bohra
@Hemant_S_Bohra 7 жыл бұрын
Thanks. How to add username field in Audit table?
@devexpost8508
@devexpost8508 7 жыл бұрын
Something like... DROP Table tblAudit CREATE TABLE tblAudit ( MessageId INT IDENTITY(1,1) PRIMARY KEY NOT NULL, EventTime DATETIME NOT NULL, TableName VARCHAR(20), UserId VARCHAR(50) NOT NULL, AuditMessage VARCHAR(1000) NOT NULL ) INSERT INTO tblAudit VALUES ( CURRENT_TIMESTAMP, 'tblEmployee', USER_NAME(), 'Record ID=' + CAST(@Id1 AS VARCHAR(6)) + ' ', + @AuditString)
@mdmohshinctg
@mdmohshinctg 3 жыл бұрын
@@devexpost8508 USER_NAME()??
@mahebunissask6051
@mahebunissask6051 8 жыл бұрын
hi.. i had done perfectly with after triggers ( insert,delete).. when update comes i got one table ( tblemployee) updates data,,,but tblemployeeaudit table doesnt showing the data.. plz anybody clarify my doubt..
@micbarpia
@micbarpia 4 жыл бұрын
ctrl v your code here
@UPHARANAND
@UPHARANAND 4 жыл бұрын
I am still confused why u have created temp table. I tried the same program but without temp table, I got error. I can't understand the logic
@hkmusc
@hkmusc 3 жыл бұрын
Presumbly it is due to the read-only nature of the INSERTED table. That's why you have to copy the whole INSERTED table into a temporary table so that every processed row could be deleted.
@sudarshanpatil2227
@sudarshanpatil2227 2 жыл бұрын
you can not delete data directly from the inserted table that`s why we need to copy it into another table which is nothing but a temp table So now you can delete data from the temp table So I hope your all doubts are cleared. thank you .
@igorkovac8509
@igorkovac8509 8 жыл бұрын
Very nice :)
@samkommula3805
@samkommula3805 8 жыл бұрын
the lengthy query which you have written at the bottom from gender to old department is not clearly seen, kindly scroll it to the right so that we can see the whole query clearly. all of your videos was good except this because the right side part of query is missing. kindly write the query again.
@yareddz1124
@yareddz1124 8 жыл бұрын
csharp-video-tutorials.blogspot.com You can access all his videos slides in this link.
@werthero
@werthero 12 жыл бұрын
Awesome.
@geetachiddarwar4391
@geetachiddarwar4391 3 жыл бұрын
can anyone help me how he create audit table with what data type
@zhangxd128
@zhangxd128 6 жыл бұрын
I think using varibles is too complicated. You should use insert into ''''''' select ''''' from inserted/deleted
@Shubham_AT
@Shubham_AT 9 жыл бұрын
hello, I am getting an issue. when i update any record the output of the EmployeeAudit table is ( Employee with Id=2 changed) . So, my issue is that why it shows me the output upto changed only, where is the rest of the output gone. I had follwed the same flow as explained in the given video. plzzz help
@SuperGojeto
@SuperGojeto 9 жыл бұрын
+Shubham Mittal double check these statements- Set @AuditString = @AuditString+........rest of logic if the second @AuditString is missing then u won't see the 'changed from' +'to' output.
@tuhoctiengtrunghichinese
@tuhoctiengtrunghichinese 8 жыл бұрын
I think you have to change the length of AuditData to nvarchar(1000)
@orhanbakuvi
@orhanbakuvi 2 жыл бұрын
very hard example for beginners
@SAJIDHUSSAIN-bb1jl
@SAJIDHUSSAIN-bb1jl 7 жыл бұрын
sir, After successfully creating update trigger when i am updating a row in table the following error showing as output.. Error: (1 row(s) affected) Msg 8152, Level 16, State 13, Procedure TR_Audit_employeeUpdate, Line 52 String or binary data would be truncated. The statement has been terminated. Update Trigger code is: Alter trigger TR_Audit_employeeUpdate on employee for update as Begin declare @Id int declare @oldname nvarchar(20), @newname nvarchar(20) declare @oldsalary int, @newsalary int declare @oldGender nvarchar(20), @newGender nvarchar(20) declare @oldCity nvarchar(20), @newCity nvarchar(20) declare @oldDeptId int, @newDeptId int declare @AuditString nvarchar(1000) select * into #TempTable from inserted while(Exists(select Id from #TempTable)) Begin set @AuditString = '' select top 1 @Id = ID , @newname = Name, @newGender = Gender, @newsalary = Salary, @newCity = City,@newDeptId = DepartmentID from #TempTable select @oldname = Name, @oldGender = Gender, @oldsalary = Salary, @oldCity = City, @oldDeptId = DepartmentID from deleted where ID = @Id set @AuditString = 'Employee with ID = '+ CAST(@Id as nvarchar(4))+ 'changed ' if(@oldname @newname) set @AuditString = @AuditString + ' Name from ' +@oldname+ ' to ' + @newname if(@oldGender@newGender) set @AuditString = @AuditString + ' Gender from ' + @oldGender + ' to ' + @newGender if(@oldsalary@newsalary) set @AuditString = @AuditString + ' Salary from ' +CAST(@oldsalary as nvarchar(20))+ ' to ' + CAST(@newsalary as nvarchar(20)) if(@oldCity@newCity) set @AuditString = @AuditString + ' City from ' + @oldCity + ' to ' + @newCity if(@oldDeptId@newDeptId) set @AuditString = @AuditString + ' DepartmentID from ' + CAST(@oldDeptId as nvarchar(20))+ ' to ' + CAST(@newDeptId as nvarchar(20)) insert into Audit values(@AuditString) delete from #TempTable where ID = @Id End End please sir resolve this error... waiting for your response mail: sajid10.1991@gmail.com
@shyamprasadatluri7166
@shyamprasadatluri7166 5 жыл бұрын
Create the tables like the below I have entered : Create table tblEmployee ( Id int Primary Key, Name nvarchar(30), Salary int, Gender nvarchar(10), DepartmentId int ) Create table tblEmployeeAudit ( Id int identity(1,1) Primary Key, AuditData varchar(1000) ) You won't get error now
@MDARIF-yo3tq
@MDARIF-yo3tq 6 жыл бұрын
loop taking much time to be executed mean i couldn't get see result its not being executed
@sijimathew9982
@sijimathew9982 8 жыл бұрын
thank you sir
@sairojalam5044
@sairojalam5044 8 жыл бұрын
Please asp.net listview control video send and work on proper like insert update delete every type like sqldatasource,sqldataobject and without object
@jubinroy4987
@jubinroy4987 Жыл бұрын
I tried this and got an infinite loop on update statements
@hamzanazir4412
@hamzanazir4412 7 жыл бұрын
awesome sir amazing
Instead of insert trigger   Part 45
15:05
kudvenkat
Рет қаралды 277 М.
DML triggers in sql server   Part 43
17:45
kudvenkat
Рет қаралды 698 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
How to treat Acne💉
00:31
ISSEI / いっせい
Рет қаралды 108 МЛН
BAYGUYSTAN | 1 СЕРИЯ | bayGUYS
36:55
bayGUYS
Рет қаралды 1,9 МЛН
Indexes in sql server   Part 35
11:13
kudvenkat
Рет қаралды 850 М.
See images of military aircraft used to deport migrants
10:28
Stored procedures with output parameters   Part 19
18:20
kudvenkat
Рет қаралды 791 М.
CTE in sql server   Part 49
12:57
kudvenkat
Рет қаралды 439 М.
Instead of update triggers in sql server - Part 46.avi
22:27
kudvenkat
Рет қаралды 185 М.
Clustered and nonclustered indexes in sql server   Part 36
16:48
kudvenkat
Рет қаралды 968 М.