Microsoft
Software
Hardware
Network
Question : How to just grab the specifc text from T-SQL?
Hi, I'm writing a query and need to just grab a section of the string. Can anyone help?
For example: SELECT ACCOUNTNAME FROM ACCOUNT
Return results sample: 10294 - Mayberry
I need the return result to be just "Mayberry". I thought of using substring, but it appears that it can only use a set number of values for starting and ending point. I just need it to grab the account name AFTER the '-' symbol, that's what gets me.
Thanks!
Answer : How to just grab the specifc text from T-SQL?
Use CHARINDEX to find the starting point for the SUBSTRING function:
SELECT SUBSTRING(AccountName, CHARINDEX('-', AccountName) + 1, (LEN(AccountName) - (CHARINDEX('-', AccountName) + 1)) AS DelimitedAcctName FROM ACCOUNT
hth
valkyrie_nc
Random Solutions
error while executing a stored procedure
How can I check for an install new updates for Symantec Backup Exec? I have clicked on the Help drop down menu, but don't see any options for updates
Move users home folders to new storage partition
Ask user if they wish to overwrite existing file
simple math programming question
Computer doesnt power on...
Need to translate my first string in ASP.NET
Post image file [Binary Data] using HttpWebRequest fails.
what is sugar crm
Check to see if a table has a certain value, MS Access 2003