SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 In trigger split the rows by comma separated
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gangadhara.ms
Aged Yak Warrior

India
547 Posts

Posted - 03/28/2013 :  05:41:32  Show Profile  Reply with Quote
Hi All,
I have a table column with comma separated values.In the trigger after insert into main table i need to insert into history by comma separated values.

--2 tables script--

create table testing_trig
( id int ,
key_name varchar(150),
names_desc varchar(100))

create table testing_trig_his
(id int,
key_name varchar(150),
split varchar(100))

--trigger script--
CREATE TRIGGER testing_trig_insert ON testing_trig
AFTER INSERT,DELETE, UPDATE
AS
BEGIN
insert into testing_trig_his(id,key_name,split)
select id,key_name,names_desc from inserted
end

----insert script ----

insert into testing_trig values(2,'TRTOR','Gear,engine')


Here while insertign inside the trigger to "testing_trig_his" i should have 2 rows with value in GEAR one row and Engine in another row

Pls help

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 03/28/2013 :  05:55:41  Show Profile  Reply with Quote
see

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=184034

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

gangadhara.ms
Aged Yak Warrior

India
547 Posts

Posted - 03/28/2013 :  06:38:37  Show Profile  Reply with Quote
Hi Visakh,
Thanks for the reply.
But the case here is totally different ,, i need to split for comma separated and need to insert into another row.I am not much familiar with the T-SQL code pls help.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 03/28/2013 :  06:48:28  Show Profile  Reply with Quote
thats exactly what other discussion is about. did you check the illustration at all?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000