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-tutorialsBlogspot7 жыл бұрын
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
@awaisbutt90127 жыл бұрын
Its more then useful. Its an asset
@sarahaaalmhtara59874 жыл бұрын
@@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*
@mithamazumdar87944 жыл бұрын
@@Csharp-video-tutorialsBlogspot nice👍
@vishakhabinani6856 Жыл бұрын
10 years since the playlist but still helping so many students!! Love and respect to you sir!!
@anuragvashishtha666012 жыл бұрын
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.
@micbarpia4 жыл бұрын
You are the reason that normal schools should be changed for online schools with people like You ! really... MY HERO!
@seetamer11 жыл бұрын
Man, you deserve Heaven & I wish it for you :-)
@Csharp-video-tutorialsBlogspot11 жыл бұрын
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
@rezoanhasib83947 жыл бұрын
The code looks complicated, many would have made it so while explaining but you didn't. Cuz you a legend! Hats off dude.
@Thrudv7 жыл бұрын
I have a test tomorrow and I'm watching your videos. You explain everything really good so thank you very much!
@shubhenduinfotech59922 жыл бұрын
You are born teacher just A mighty gift for all the beginar developer thank you sir
@nys82604 жыл бұрын
Thank You Mr Venkat, The best teacher over the world
@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.
@Djabsey111 жыл бұрын
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-tutorialsBlogspot11 жыл бұрын
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.
@devarakondasankararao38026 ай бұрын
Easy way of understanding about triggers .Thank You Venkat Sir.
@epuriraghavendra38476 жыл бұрын
I think no one else can explain as simple as you , you are an exceptional one sir, thanks a lot :)
@KaranShah-u8w Жыл бұрын
Superb videos! I have finally been able to understand triggers! thank you so much Sir
@javielitostanley70408 жыл бұрын
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-tutorialsBlogspot8 жыл бұрын
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
@hridayaannuncio35836 жыл бұрын
Superb videos! I have finally been able to understand triggers! thank you so much
@danushkamalinga84873 жыл бұрын
The best teacher ever.
@krzysztofs85358 жыл бұрын
Bravo! These videos are very useful. Very long syntax, then longest code from the beginning of the course.
@priyankathakare27603 жыл бұрын
Very informative video..Thanks a lot from all the learners..Keep it up. 👍
@Chetan.Kothari5 жыл бұрын
Thank you so much...God bless you!!! Your videos help us to learn concept deeper and clearly.
@avinashniture68413 жыл бұрын
God bless you sir. Excellent teaching
@MsShanmathi5 жыл бұрын
Thank you so much. Your videos are very useful and its clearly explained
@JP-td8gt5 жыл бұрын
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.
@daalwada5 жыл бұрын
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.
@pavithravvenu58173 жыл бұрын
No words to say..hats off!!!!!
@sairamkandgule33653 жыл бұрын
Hi, 1:14, part 42 of the video series is view limitations. not triggers. BTW, you're an awesome teacher.
@prosperg1865 жыл бұрын
Excellent video as usual. Very well done.
@slobodantajisic2762 Жыл бұрын
Hm. What if I don't change anything in the update statement? I will enter garbage text in the tblEmployeeAudit.
@Csharp-video-tutorialsBlogspot11 жыл бұрын
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 Жыл бұрын
u r extremely super explaining sir
@daliladali12687 жыл бұрын
you are my favorite teacher,thanks a lot
@sweetysharma26213 жыл бұрын
Very interesting example ❤️
@MixTapeYT17 жыл бұрын
For everyone, try using 1.25 speed, it's understandable and you have better concentration
@MuhammadUsman-yi5cw4 жыл бұрын
Listening at 1.75 x would be much better
@reynaldoduazojr56816 жыл бұрын
This is very helpful, i thank you very much for your effort sir, thumbs up (y) !
@rogercheng75645 жыл бұрын
This is so helpful as always!
@anubhagupta54084 жыл бұрын
Amazing explaination. Thank you
@xavierdupont57726 жыл бұрын
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.
@stephennguyen80528 жыл бұрын
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?
@stephennguyen80528 жыл бұрын
I figured it out, thanks kudvenkat
@justina75088 жыл бұрын
'Hi guys, I like to ask questions, then after figuring out the answer I don't post the solution for others to use.'
@stephennguyen80528 жыл бұрын
I didn't think anyone else would run into the same issue~
@mahebunissask60518 жыл бұрын
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..
@rahultiwari77448 жыл бұрын
Ak Number sir , what a way to Teach
@hariz61544 жыл бұрын
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.
@robbinshee11 жыл бұрын
You are a life saver !!!!
@pradeepdhamija5695 жыл бұрын
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_shugal27057 жыл бұрын
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.
@devi0746111 жыл бұрын
hi venkat, i am getting this "Column name or number of supplied values does not match table definition." ? while creating the trigger
@utkristpandey66414 жыл бұрын
Same problem, it didn't take id value Automatically that's why..
@davidz8786 жыл бұрын
Why did salary increase when you changed gender from female to male at 3:30?
@hrvooje2 жыл бұрын
Why not use inserted table for while loop? Doesn'tt it contain multiple rows?
@bornofdata4 жыл бұрын
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?
@markotomic79764 жыл бұрын
Should we join inserted table and the table we use to get data from ?
@mohanprabhu30916 жыл бұрын
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-ox3ks11 жыл бұрын
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.
@prudhvik56032 жыл бұрын
when we are using top 1 from temptable isnt that will be the same row we are always selecting?
@prudhvik56032 жыл бұрын
okay got it. we are deleting that row at the end
@JP-td8gt5 жыл бұрын
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?
@kingnaveen59856 жыл бұрын
hello sir,in this video,your mention slide-42(DML Trriger),but actualy slide-42 is (View limitations concept).
@sajateacher9 жыл бұрын
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?
@SuperGojeto9 жыл бұрын
+Ryan Blais copy paste the error and code here then someone can guess what's the error.
@devenmhatre7278 жыл бұрын
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
@larabsteve33508 жыл бұрын
I think u made mistake on insert into tblemployeeAudit. this table takes only two value.
@sisaysarke5888 жыл бұрын
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.
@yareddz11248 жыл бұрын
csharp-video-tutorials.blogspot.com If you go to the link above, you can access all slide with the script.
@nandhinibaskaran75783 жыл бұрын
for inserted why we are using a separate temp table. is there any purpose for this
@pramodmaurya66106 жыл бұрын
Thanks for your knowledge sharing..
@gaureesha98409 жыл бұрын
Can we directly use inserted table in the while condition? Why do we need the temporary table?
@deboadeyemi6 жыл бұрын
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.
@nys82604 жыл бұрын
you can't remove rows from inserted table
@shanshanli784910 жыл бұрын
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;-)
@mdmohshinctg3 жыл бұрын
sir, how get/insert end user id/name into audit table using Update trigger when i using c#
@sheogorathmadgod34477 жыл бұрын
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
@sheogorathmadgod34477 жыл бұрын
oops sorry.... you are deleting only an id.every cycle..and there is no shifting to another record....
@josephregallis33947 жыл бұрын
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.
@shahbazalam45656 жыл бұрын
Wow...I am a fan
@SathishKumar-gs4er8 жыл бұрын
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...
@zooniesheikh31342 жыл бұрын
just amazing.
@VF7RM8 жыл бұрын
I didn't get where the #TempTable come from....Was it previously created? Or it gets created with the statement inside the trigger?
@LiamFoot8 жыл бұрын
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.
@VF7RM8 жыл бұрын
+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
@Mayankg3038 жыл бұрын
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
@DodgerDude746 жыл бұрын
created on the fly if you haven't already explicitly declared it
@dunai20125 жыл бұрын
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 .
@mohammedalkhafaf42296 жыл бұрын
it is very useful thanks
@vinayakshukla24553 жыл бұрын
please may you tell why loop become infinite loop if i not delete id from #temptable
@Felixantony8410 жыл бұрын
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_shugal27057 жыл бұрын
Which data type use in Audit column....
@semrithiro93866 жыл бұрын
Where will deleted row go when we delete it from deleted table?
@neetusinha14 жыл бұрын
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!
@hostname476 жыл бұрын
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
@momen15310 жыл бұрын
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.
@SuperGojeto9 жыл бұрын
+عمار رصرص that means you should not insert id values in id column, that will be done automatically.
@momen1539 жыл бұрын
thank you very much
@SuperGojeto9 жыл бұрын
عمار رصرص your welcome :)
@Hemant_S_Bohra7 жыл бұрын
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.
@jade101ism8 жыл бұрын
you left out the is deleted section of the code :(
@stutitehri99310 жыл бұрын
great videos
@jyothikrishna258811 жыл бұрын
Surampudi Tpdevi ..I think you didn set the Id column as identity column thats why you get this error...
@tejaswininandam63592 жыл бұрын
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.
@piyasidey21174 жыл бұрын
What is the difference between part 43 and part 44..I can't found any.
@piyasidey21174 жыл бұрын
Thank you sir.
@Chetan.Kothari5 жыл бұрын
Thank you!!!
@Hemant_S_Bohra7 жыл бұрын
Thanks. How to add username field in Audit table?
@devexpost85087 жыл бұрын
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)
@mdmohshinctg3 жыл бұрын
@@devexpost8508 USER_NAME()??
@mahebunissask60518 жыл бұрын
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..
@micbarpia4 жыл бұрын
ctrl v your code here
@UPHARANAND4 жыл бұрын
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
@hkmusc3 жыл бұрын
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.
@sudarshanpatil22272 жыл бұрын
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 .
@igorkovac85098 жыл бұрын
Very nice :)
@samkommula38058 жыл бұрын
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.
@yareddz11248 жыл бұрын
csharp-video-tutorials.blogspot.com You can access all his videos slides in this link.
@werthero12 жыл бұрын
Awesome.
@geetachiddarwar43913 жыл бұрын
can anyone help me how he create audit table with what data type
@zhangxd1286 жыл бұрын
I think using varibles is too complicated. You should use insert into ''''''' select ''''' from inserted/deleted
@Shubham_AT9 жыл бұрын
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
@SuperGojeto9 жыл бұрын
+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.
@tuhoctiengtrunghichinese8 жыл бұрын
I think you have to change the length of AuditData to nvarchar(1000)
@orhanbakuvi2 жыл бұрын
very hard example for beginners
@SAJIDHUSSAIN-bb1jl7 жыл бұрын
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
@shyamprasadatluri71665 жыл бұрын
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-yo3tq6 жыл бұрын
loop taking much time to be executed mean i couldn't get see result its not being executed
@sijimathew99828 жыл бұрын
thank you sir
@sairojalam50448 жыл бұрын
Please asp.net listview control video send and work on proper like insert update delete every type like sqldatasource,sqldataobject and without object
@jubinroy4987 Жыл бұрын
I tried this and got an infinite loop on update statements