Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 In trigger split the rows by comma separated

Author  Topic 

gangadhara.ms
Aged Yak Warrior

549 Posts

Posted - 2013-03-28 : 05:41:32
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

52326 Posts

Posted - 2013-03-28 : 05:55:41
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

549 Posts

Posted - 2013-03-28 : 06:38:37
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

52326 Posts

Posted - 2013-03-28 : 06:48:28
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
   

- Advertisement -