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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-01-20 : 07:15:02
|
david writes "Uncle!I have a column in a log table that has a "message" field which is overloaded with lots of data separated by "|". I am hoping to have a trigger execute each time a record is added to the Log table which breaks apart this delimited string and updates the same record with the data for each field.For example:Log Record before Trigger:message name age ipaddressdavid|45|45.34.23.43 (null) (null) (null)Log Record after Trigger:message name age ipaddressdavid|45|45.34.23.43 david 45 45.34.23.43 There must be a reasonable way to do this but hours into it, I have hit too many hurtles even though I came across fn_split() UDF that provides a general breaking apart of a delimited string .... it, however, leaves me with a two-column table that I am not sure what to do with!The reference for fn_split() is : http://www.winnetmag.com/SQLServer/Article/ArticleID/21071/21071.htmlI appreciate any help getting me to this trigger ..." |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2005-01-20 : 07:17:39
|
| This might help:http://www.sqlteam.com/item.asp?ItemID=15044Something like:SELECT Replace(Parsename(Replace(Replace(message, '.', '*'), '|', '.'),1),'*', '.') AS IPAddress,Parsename(Replace(Replace(message, '.', '*'), '|', '.'),2) AS Age,Parsename(Replace(Replace(message, '.', '*'), '|', '.'),3) AS NameFROM myLogTable |
 |
|
|
|
|
|
|
|