Wednesday, March 21, 2012

Manupulate a astring

Hi,
I have a string like this
16/09/2005 12:46 PM 2,673,387,008 DTS_db_200509161242.BAK
i want to cut the string from right side like this
DTS_db_200509161242.BAK how can i do that i used substring with
charindex and len in a string but i am not able to get i want.
pls help
Thanx
from
Dollerhi doller
kindly try this scripts
declare @.text nvarchar(2000)
select @.text='16/09/2005 12:46 PM 2,673,387,008 DTS_db_200509161242.BAK'
select @.text=reverse(@.text)
select @.text=substring(@.text, 1, charindex(' ', @.text))
select ltrim(reverse(@.text))
thanks,
--
Jose de Jesus Jr. Mcp,Mcdba
Data Architect
Sykes Asia (Manila philippines)
MCP #2324787
"doller" wrote:
> Hi,
> I have a string like this
> 16/09/2005 12:46 PM 2,673,387,008 DTS_db_200509161242.BAK
> i want to cut the string from right side like this
> DTS_db_200509161242.BAK how can i do that i used substring with
> charindex and len in a string but i am not able to get i want.
> pls help
> Thanx
> from
> Doller
>|||Assuming that "DTS" is the delimiter
DECLARE @.String varchar(100)
SET @.String = '16/09/2005 12:46 PM 2,673,387,008
DTS_db_200509161242.BAK'
Select RIGHT(@.String,LEN(@.String)-CHARINDEX('DTS',@.String) +1)
HTH, Jens Suessmeyer.|||i did it before like this
select substring(mycolumn,1,12) as
date,reverse(substring(reverse(mycolumn),0,charindex('
',reverse(mycolumn)))) as name from #temp1
but i dont want to use as it take lot of process.
i have to do it for 50,000,000+ rows
pls help
from
Doller|||Thanx Jens
This is really fast.
from
DOller

No comments:

Post a Comment