﻿<?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 2005 / T-SQL (SS2K5)  / trigger update and compare string !? / 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 14:40:07 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Sorry! I dont know that.I creat my thread :[url]http://www.sqlservercentral.com/Forums/Topic1365604-392-1.aspx[/url]</description><pubDate>Thu, 27 Sep 2012 23:07:56 GMT</pubDate><dc:creator>maida_rh</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>[quote][b]maida_rh (9/26/2012)[/b][hr][b][font="Arial Black"]I want to compare a column value if following char are in the string then need to split it ?MY C# CODE :[/font][/b][code="other"]string val = strtxt.Text.Trim();        if (val.Contains("N") == true &amp;&amp; val.Contains("E") == true &amp;&amp; val.Contains("M") == true &amp;&amp; val.Contains("H") == true &amp;&amp; val.Contains("T") == true &amp;&amp; val.Contains("V") == true &amp;&amp; val.Contains("L") == true &amp;&amp; val.Contains("C") == true)        {            string[] pvalues = val.Split(new char[] { 'N', 'E', 'M', 'H', 'T', 'V', 'L', 'C' });            foreach (string s in pvalues)            {                if (s.Trim() != "")                {                    lstsplit.Items.Add(s);                    lblmsg.Text = "split succesfully";                }            }        }        else        {            lblmsg.Text = "split cant be done";                    }[/code][font="Arial Black"]I used above code to compare and split the string and want to do in sql server trigger after insert on table. Any help regarding this.[b][/b][/font][/quote]You should not hijack someone else's thread. Instead you should start your own. I would however recommend that before you start a thread that you read the first link in my signature about best practices when posting questions. Your post raises more questions then it answers. Why in a trigger? Are you familiar with string splitting in sql? If not, then you should read the article in my signature about splitting strings. The more details you provide in your question the better the answer you will get.</description><pubDate>Wed, 26 Sep 2012 07:52:51 GMT</pubDate><dc:creator>Sean Lange</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>[b][font="Arial Black"]I want to compare a column value if following char are in the string then need to split it ?MY C# CODE :[/font][/b][code="other"]string val = strtxt.Text.Trim();        if (val.Contains("N") == true &amp;&amp; val.Contains("E") == true &amp;&amp; val.Contains("M") == true &amp;&amp; val.Contains("H") == true &amp;&amp; val.Contains("T") == true &amp;&amp; val.Contains("V") == true &amp;&amp; val.Contains("L") == true &amp;&amp; val.Contains("C") == true)        {            string[] pvalues = val.Split(new char[] { 'N', 'E', 'M', 'H', 'T', 'V', 'L', 'C' });            foreach (string s in pvalues)            {                if (s.Trim() != "")                {                    lstsplit.Items.Add(s);                    lblmsg.Text = "split succesfully";                }            }        }        else        {            lblmsg.Text = "split cant be done";                    }[/code][font="Arial Black"]I used above code to compare and split the string and want to do in sql server trigger after insert on table. Any help regarding this.[b][/b][/font]</description><pubDate>Wed, 26 Sep 2012 06:11:59 GMT</pubDate><dc:creator>maida_rh</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>[quote][b]christophe.bernard 47659 (1/6/2011)[/b][hr]Hi,thanks you so much for your sample now i understand that we can add a relation between the table deleted and inserted ..Sorry i'm a beginner and i WANT to understand ;)thanks and have a nice year ..Christophe[/quote]Glad I could help and welcome to SSC!!!</description><pubDate>Thu, 06 Jan 2011 07:52:07 GMT</pubDate><dc:creator>LutzM</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Hi,thanks you so much for your sample now i understand that we can add a relation between the table deleted and inserted ..Sorry i'm a beginner and i WANT to understand ;)thanks and have a nice year ..Christophe</description><pubDate>Thu, 06 Jan 2011 07:28:29 GMT</pubDate><dc:creator>christophe.bernard 47659</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Here's a setup to play with including some tests to check whether a sproc will be fired or not.[code="sql"]USE tempdbGOif object_id('temp','U') is not null drop table tempCREATE TABLE temp( idCourse INT, Libelle VARCHAR(300))GOCREATE TRIGGER compare ON tempINSTEAD OF UPDATE ASBEGIN -- check if there is one single row where the value of column Libelle has changed	IF EXISTS 		(			SELECT 1 			FROM DELETED d 			INNER JOIN INSERTED i ON i.idCourse = d.idCourse			WHERE i.Libelle &amp;lt;&amp;gt; d.Libelle		)	BEGIN		PRINT 'FIRE STORE PROCEDURE'	END	ELSE	BEGIN		PRINT 'NOT FIRE STORED PROCEDURE'	ENDENDGOINSERT INTO tempSELECT 1,'1' UNION ALLSELECT 2,'2'UPDATE temp SET Libelle = Libelle+1 UPDATE temp SET Libelle = Libelle+1 WHERE idCourse = 2UPDATE temp SET Libelle = LibelleWHERE idCourse = 2UPDATE temp SET Libelle = Libelle+1 WHERE idCourse = 3[/code]</description><pubDate>Wed, 05 Jan 2011 07:48:15 GMT</pubDate><dc:creator>LutzM</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Hi lutz,sorry but i can't understand !?have you got an example or the method i must to use ?!no it"s not a homework ;-(thanks christophe</description><pubDate>Wed, 05 Jan 2011 06:18:39 GMT</pubDate><dc:creator>christophe.bernard 47659</dc:creator></item><item><title>RE: trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Your approach will only compare the first updated value, whereas "first" is equal "first random" in this case since there is no ORDER BY.When you use triggers always make sure to be ready to deal with multiple result sets.So, instead of assigning the first value to a variable, compare the two tables (inserted and deleted) directly using NOT EXISTS().Question aside (please, don't get me wrong): is this some kind of homework?</description><pubDate>Wed, 05 Jan 2011 04:42:31 GMT</pubDate><dc:creator>LutzM</dc:creator></item><item><title>trigger update and compare string !?</title><link>http://www.sqlservercentral.com/Forums/Topic1042941-338-1.aspx</link><description>Hi,i'm a beginner with t sql =&amp;gt; sql server 2005.i have this table : T_courses with these fields : idCourse (int), Libelle varchar(300), dateCourse (datetime)i must to create a trigger who is fired on update table =&amp;gt; T_COURSESbut with the old libelle and new libelle i must to compare these two field AND if there is a difference fire a stored proceduremy question is: how to compare these two strings ?here is it my code for the moment :[quote]CREATE TRIGGER TR_COURS_UPDATE ON T_COURSESFOR UPDATEASdeclare @oldLibelle varchar(300)declare @newLibelle varchar(300)SELECT @oldLibelle = (SELECT TOP 1 FROM DELETED)SELECT @newLibelle = (SELECT TOP 1 FROM INSERTED)IF(oldLibelle &amp;lt;&amp;gt; @newLibelle) -- =&amp;gt; how to compare these stringBEGIN	PRINT 'FIRE STORE PROCEDURE'ENDELSEBEGIN	PRINT 'NOT FIRE STORED PROCEDURE'END[/quote]THANKS FOR YOUR TIME AND SAMPLE !do you think my code is ok ?happy new year..guysChristophe</description><pubDate>Wed, 05 Jan 2011 04:28:42 GMT</pubDate><dc:creator>christophe.bernard 47659</dc:creator></item></channel></rss>