November 5, 2008 at 10:00 am
i have varchar column.
for ex: 123-458-856 -AD45 EXP 01/01/01
i wantto separate all the values after EXP into another new column.
wht is easiest way to deal with this?
Thanks in advance
A
November 5, 2008 at 10:16 am
November 5, 2008 at 10:22 am
Hi
This is a basic example you may need to change it if you don't want leading spaces etc.
DECLARE @string VARCHAR(100)
SET @string = '123-458-856 -AD45 EXP 01/01/01'
SELECT
@string as [My String],
LEFT(@string,CHARINDEX('EXP',@string,0)-1) as [Column 1],
RIGHT(@string,LEN(@string)+2 - CHARINDEX('EXP',@string,0)) as [Column 2]
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
November 5, 2008 at 10:27 am
seems to me like your data after exp is a date, so make it a datetime column !
pro:
- only date(time) values accepted
- the whole bunch of datetime related functions
con:
- no invalid dates allowed :w00t:
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply