July 23, 2013 at 10:44 am
i have a column abc_col1 in table A
when i do a ("Select abc_col1 from A")
i get the results as
'SHT234'
'SHT56'
'SHT7980'
i need to get the above result as
't234'
't56'
't7980'
Please advice
thanks
July 23, 2013 at 10:47 am
Never mind i just got it worked
July 23, 2013 at 12:19 pm
Glad I could help!! 🙂
Perhaps you could post your solution? One reason is so others can search for your issue and find a solution. The other is that your solution could be made even better. No downside, other than a few minutes of your time.
Best,
Kevin G. Boles
SQL Server Consultant
SQL MVP 2007-2012
TheSQLGuru on googles mail service
July 24, 2013 at 2:54 pm
A couple techniques:
SELECT RIGHT(abc_col1,len(abc_col1)-2)
FROM tableA
SELECT REPLACE(abc_col1,'SH','')
FROM tableA
-- Itzik Ben-Gan 2001
July 26, 2013 at 3:52 pm
Use length and then substring funtionc
July 27, 2013 at 9:50 am
iamsql1 (7/26/2013)
Use length and then substring funtionc
It's easy to get to the moon. All you need to do is build a rocket ship. 😉
How would YOU use what you suggested to accomplish the task? Some code would be a big help.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 27, 2013 at 2:35 pm
Jeff Moden (7/27/2013)
iamsql1 (7/26/2013)
Use length and then substring funtioncIt's easy to get to the moon. All you need to do is build a rocket ship. 😉
How would YOU use what you suggested to accomplish the task? Some code would be a big help.
SUBSTRING(column, 3, len(column));
Use Column name in first and last place of argument.
July 27, 2013 at 3:27 pm
iamsql1 (7/27/2013)
Jeff Moden (7/27/2013)
iamsql1 (7/26/2013)
Use length and then substring funtioncIt's easy to get to the moon. All you need to do is build a rocket ship. 😉
How would YOU use what you suggested to accomplish the task? Some code would be a big help.
SUBSTRING(column, 3, len(column));
Use Column name in first and last place of argument.
That'll work. Thanks for posting it.
As a bit of a sidebar, you can avoid the extra calculation of LEN depending on what you intend to do with the result.
SUBSTRING(column,3,8000)
--Jeff Moden
Change is inevitable... Change for the better is not.
July 27, 2013 at 3:28 pm
koolme_85 (7/23/2013)
Never mind i just got it worked
Very cool. What did you do to fix it?
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply