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)
 Split value

Author  Topic 

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2005-03-09 : 23:25:15
How would you split this...


MyString
------------------------
Aida-Lou
Testing-lng



Split the values by the delimeter "-"

result should look like this...



MyString1 MyString2
-------------------------------------
Aida Lou
Testing lng


Want Philippines to become 1st World COuntry? Go for World War 3...

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-03-10 : 00:15:00
[code]
select
substring(MyString,1,charindex('-',MyString)-1) as MyString1,
substring(MyString,charindex('-',MyString)+1,len(MyString)) as MyString2
from
(
select MyString = 'Aida-Lou' union all
select MyString = 'Testing-lng'
) a


MyString1 MyString2
----------- -----------
Aida Lou
Testing lng

(2 row(s) affected)


[/code]

CODO ERGO SUM
Go to Top of Page

jonasalbert20
Constraint Violating Yak Guru

300 Posts

Posted - 2005-03-10 : 00:40:13
tnx michael

Want Philippines to become 1st World COuntry? Go for World War 3...
Go to Top of Page
   

- Advertisement -