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 2000 Forums
 Transact-SQL (2000)
 String Split

Author  Topic 

wira_chen
Starting Member

4 Posts

Posted - 2005-12-21 : 03:16:23
Hi Bro,
Could you help me about split string? I want to split a string and insert it to a new tabel
example : i have a field (description)and description containts :
Description
12/8/2005 9:00:48 2005_12_8_8_52_3_173633 L_U3_GOV_TURBINETRIP To 0
12/8/2005 9:15:35 2005_12_8_9_11_11_985836 L_U3_TX_WINDINGOVER To 1
12/8/2005 9:11:14 2005_12_8_8_52_3_173633 L_U3_CB_BREAKERCLOSEDTo 1

i want to split string in description field make to :
Date Time Value Description
2005_12_8 8_52_3 173633 L_U3_GOV_TURBINE TRIP To 0
2005_12_8 9_11_11 985836 L_U3_TX_WINDING OVER To 1
2005_12_8 8_52_3 173633 L_U3_CB_BREAKER CLOSEDTo 1

so i want split the string by 'backspace'
i'm use sql server to a database connection
Can you help me about this bro?? thank's for your interesting.

Regards

Wira Chan

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-12-21 : 04:10:53
Refer this
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=50648

Madhivanan

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

Frank Kalis
Constraint Violating Yak Guru

413 Posts

Posted - 2005-12-21 : 04:13:10
Also: http://www.sommarskog.se/arrays-in-sql.html

--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Heute schon gebloggt? http://www.insidesql.de/blogs
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-12-21 : 04:13:29
Hi Bro,

Backspace dellimmiter?
as in Ascii cahracter 8?

Try this.
SELECT
LEFT(COL1, CHARINDEX(CHAR(8), COL1) - 1) [DATE_TIME],
SUBSTRING(COL1, CHARINDEX(CHAR(8), COL1) + 1, CHARINDEX(CHAR(8), COL1, CHARINDEX(CHAR(8), COL1) + 1) - CHARINDEX(CHAR(8), COL1) -1) [Value],
RIGHT(COL1, CHARINDEX(CHAR(8), REVERSE(COL1)) - 1)
FROM
MyTable

Cheers Bro.


Duane.
"It's a thankless job, but I've got a lot of Karma to burn off."
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-12-21 : 04:26:47
>>Backspace dellimmiter?
>>as in Ascii cahracter 8?

i think it should be 'blank space'

-----------------
[KH]

Learn something new everyday
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2005-12-21 : 04:30:25
>> i think it should be 'blank space'

I doubt that - the description field contains blank spaces, but if blank spaces are being used as a dellimitter - i think it would be quite silly.



Duane.
"It's a thankless job, but I've got a lot of Karma to burn off."
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-12-21 : 06:14:18
>> I doubt that - the description field contains blank spaces, but if blank spaces are being used as a dellimitter - i think it would be quite silly.
hmmmm..... maybe you are right

-----------------
[KH]

Learn something new everyday
Go to Top of Page

wira_chen
Starting Member

4 Posts

Posted - 2005-12-21 : 21:56:21
Thank's For your all Information, Bro!
Regards

Wira Chen
Go to Top of Page
   

- Advertisement -