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)
 parse a field to other fields via trigger

Author  Topic 

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-11-18 : 11:13:58
my trigger takes info from tables sticks in auditTable.. I have a field I pass in to original table that i want to parse and insert into the auditTable.. Could someone help me with this trigger?

want to use "~" as delimiter


[dbo].[M8_Customers] Example
ID | Audit
1 col1_txt~col2_txt~col3_txt




[dbo].[LogSQL]
ID | col1 | col2 | col3 | language_event | parameters | event_info


trigger currently
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

-- Audit trigger
ALTER TRIGGER [dbo].[LogSQL]
ON [dbo].[M8_Customers]
AFTER INSERT, UPDATE, DELETE
AS
INSERT INTO dbo.PB_Logs (language_event, parameters, event_info)
EXEC('DBCC INPUTBUFFER(@@SPID);');

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-23 : 09:23:45
Do you want to split into multiple columns?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-23 : 09:29:20
are you trying to generating audit values as delimited list?
Go to Top of Page

cwfontan
Yak Posting Veteran

87 Posts

Posted - 2009-11-23 : 10:22:42
quote:
Originally posted by madhivanan

Do you want to split into multiple columns?

Madhivanan

Failing to plan is Planning to fail



Yes I want to split into multiple columns.

string = "Value1~value2~value3"

trigger to insert string into (col1, col2, col3)(Value1,value2,value3)

And keep the current trigger insert as well**
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-11-23 : 11:09:02
use the below solution
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=118014
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-25 : 00:57:49
or
http://sqlblogcasts.com/blogs/madhivanan/archive/2008/09/11/splitting-delimited-data-to-columns-set-based-approach.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -