﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Trigger to update existing records / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 18 May 2013 06:25:53 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>[quote][b]Lowell (12/20/2012)[/b][hr]UPDATE [table] SET [col] = [col] Seriously? that is the trigger body? updating the column to itself, with referencing the INSERTED virtual table?[/quote]It's not the trigger body... is the sql statement to fire the trigger on the table...Try changing the AFTER INSERT, UPDATE to FOR INSERT, UPDATE.The UPDATE table SET col = col should fire the trigger, I use it often when I want to do exactly what your're trying to accomplish..</description><pubDate>Fri, 21 Dec 2012 02:27:43 GMT</pubDate><dc:creator>PiMané</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>UPDATE [table] SET [col] = [col] Seriously? that is the trigger body? updating the column to itself, with referencing the INSERTED virtual table?Remember we are not in your cube looking over your shoulder; we can only help you if you help us by providing the complete, real update command.there's got to be much much more than you are telling us, because base don what I've seen so far, it seems you are trying to do something like this:[code]UPDATE PROD SET Product_Name_Expiry = getdate()WHERE Product_Name_Expiry IS NULL[/code]that is the most basic of UPDATE commands, and your trigger must be more complex than the code you pasted, otherwise you wouldn't need a trigger at all.</description><pubDate>Thu, 20 Dec 2012 06:18:54 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Updated by below query UPDATE [table] SET [col] = [col] but trigger is not firing on update.below is my triggerCREATE TRIGGER [dbo].[Prod]    ON [dbo].[Table_Name]    AFTER INSERT,UPDATE</description><pubDate>Thu, 20 Dec 2012 06:10:10 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>If you don't have the UPDATED validation on the TRIGGER you can do a simple UPDATE [table] SET [col] = [col] and that will do nothing to your data but will fire the trigger.Pedro</description><pubDate>Thu, 20 Dec 2012 05:59:24 GMT</pubDate><dc:creator>PiMané</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>[quote][b]Minnu (12/20/2012)[/b][hr]Am having a table called products with 4 columns, whenever any new insert or update happens,column "Product_Name_Expiry" will be udpated with prouduct_Name : Product_expriry_date.ID	Product_Name	Product_Expiry_Date	                 Product_Name_Expiry--	------------	------------------------	                   ---------------------------------1001	Veh		2012-08-20 00:00:00.000	                  Veh	: 2012-08-20 00:00:00.0001075	STL		2012-08-20 00:00:00.000	                  STL	: 2012-08-20 00:00:00.0001081	TKL		2012-08-20 00:00:00.000	                 TKL	: 2012-08-20 00:00:00.0001569	JKT		2012-08-20 00:00:00.000	                 JKT	: 2012-08-20 00:00:00.0001012	Veh		2012-08-20 00:00:00.000	                   NULL	1013	STL		2012-08-20 00:00:00.000	                   NULL	1014	TKL		2012-08-20 00:00:00.000	                   NULL	1515	JKT		2012-08-20 00:00:00.000	                   NULL	ID : 1001, 1075, 1081,1569 are the new inserted / updated records, hence trigger fired and product_name_expriry,My requirement i want to udpate proudct_name_expiry is without updating existing records "1012,1013,1014,1015" i want a one time stored procedure to udpate existing records.[/quote]so, are you going to post the CREATE TRIGGER code and the CREATE TABLE definition?If you want to perform the same update as the trigger, we need the code of the trigger.you undoubtedly would have had a working answer yesterday if you had the chance to post the code.</description><pubDate>Thu, 20 Dec 2012 05:51:35 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Am having a table called products with 4 columns, whenever any new insert or update happens,column "Product_Name_Expiry" will be udpated with prouduct_Name : Product_expriry_date.ID	Product_Name	Product_Expiry_Date	                 Product_Name_Expiry--	------------	------------------------	                   ---------------------------------1001	Veh		2012-08-20 00:00:00.000	                  Veh	: 2012-08-20 00:00:00.0001075	STL		2012-08-20 00:00:00.000	                  STL	: 2012-08-20 00:00:00.0001081	TKL		2012-08-20 00:00:00.000	                 TKL	: 2012-08-20 00:00:00.0001569	JKT		2012-08-20 00:00:00.000	                 JKT	: 2012-08-20 00:00:00.0001012	Veh		2012-08-20 00:00:00.000	                   NULL	1013	STL		2012-08-20 00:00:00.000	                   NULL	1014	TKL		2012-08-20 00:00:00.000	                   NULL	1515	JKT		2012-08-20 00:00:00.000	                   NULL	ID : 1001, 1075, 1081,1569 are the new inserted / updated records, hence trigger fired and product_name_expriry,My requirement i want to udpate proudct_name_expiry is without updating existing records "1012,1013,1014,1015" i want a one time stored procedure to udpate existing records.</description><pubDate>Thu, 20 Dec 2012 02:16:05 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Please post code, data and expected outcome as per the second link in my signature.</description><pubDate>Wed, 19 Dec 2012 08:12:47 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Yes,i want to update pre-existing data,at present trigger is firing for only newly updated or inserted records.i want Trigger should be fired one time for pre-existing data....Please help</description><pubDate>Wed, 19 Dec 2012 08:11:44 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>[quote][b]Minnu (12/19/2012)[/b][hr]Yes,i want to update pre-existing data,at present trigger is firing for only newly updated or inserted records.i want Trigger should be fired one time for pre-existing data....Please help[/quote]well, here's the basic framework:1. read the trigger code.2. copy and paste it as an UPDATE statement3., Modify/change the where statement to affect only records that are not yet affected.again, without details, we can only offer vague suggestions.</description><pubDate>Wed, 19 Dec 2012 07:38:23 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Yes,i want to update pre-existing data,at present trigger is firing for only newly updated or inserted records.i want Trigger should be fired one time for pre-existing data....Please help</description><pubDate>Wed, 19 Dec 2012 07:26:58 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>[quote][b]Minnu (12/19/2012)[/b][hr]Hi Team,Am having a trigger, which will update a column when insert / update occurs,for new inserting or updating records trigger is working fine, butam having a table, which already have multiple records, how to fire the same trigger for existing records to update column using a stored procedure[/quote]i think you'll have to post the table definition(CREATE TABLE....) and the CREATE TRIGGER .... commands for us to be able to give you any sort of intelligent answer.Post that, and be more specific about what you want to update, and i'm sure we can help.it sounds more like you want to apply the same  logic in the trigger against pre-existing data that existed before the trigger was added, and much less to do with the trigger itself, but i may be reading this wrong without more details.</description><pubDate>Wed, 19 Dec 2012 07:18:41 GMT</pubDate><dc:creator>Lowell</dc:creator></item><item><title>Trigger to update existing records</title><link>http://www.sqlservercentral.com/Forums/Topic1398388-391-1.aspx</link><description>Hi Team,Am having a trigger, which will update a column when insert / update occurs,for new inserting or updating records trigger is working fine, butam having a table, which already have multiple records, how to fire the same trigger for existing records to update column using a stored procedure</description><pubDate>Wed, 19 Dec 2012 07:12:07 GMT</pubDate><dc:creator>Minnu</dc:creator></item></channel></rss>