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)
 Finding Last ] in a String

Author  Topic 

mjb1969
Starting Member

1 Post

Posted - 2009-02-21 : 12:03:19
Hello,

I have a little dilemma with getting text from a field. I'm trying to find the last ']' in the field and start my substr from that point on. The problem is that those characters may repeat many times in the field and they are not always the same number.

[Resolved - Forwarding to Group for Closure Reason : Completed] [Priority changed from 4 to 2] [Closed] [Customer Updated] COMPLETED

[Resolved - Forwarding to Group: Support Center for Closure Reason : Completed] [Priority changed from 4 to 2] [Closed] COMPLETED

I started my substr to start at a specific point based on the data I got during testing and that got me in trouble when the fields started being different sizes and didn't grab the COMPLETED text that I wanted.

Thank you for all your help.

Thanks,
Monty

Monty
System Administrator

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-02-21 : 12:35:48
[code]SELECT RIGHT(FIELD,CHARINDEX(']',REVERSE(FIELD))-2)
FROM YOURTABLE
[/code]
Go to Top of Page
   

- Advertisement -