Groups | Blog | Home
all groups > sql server dts > november 2004 >

sql server dts : SQL issue?


Steve
11/11/2004 8:03:05 AM
Hi

I have column FName of varchar type.

FName
------
Mktg_2004_03_11Completed
Fin_2004_03_10Test
Acct_2004_03_09Failed

I want to get get result set as

FName
------
20040311
20040310
20040309

I tried using replace, stuff but couldn't make it work.

Plz. help

Allan Mitchell
11/11/2004 8:23:15 PM
Here is how you do it from the format of the data you have provided

Look for the First _ character from the left of the string. This is the
position at which you start
Look for the first _ character from the right of your string and add two
places. This is there you end.
Use substring to grab the String i.e.

2004_03_11

Now use Replace to replace the _ with ''


--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
www.Konesans.com


[quoted text, click to view]

AddThis Social Bookmark Button