dbTalk Databases Forums  

SQL issue?

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss SQL issue? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Steve
 
Posts: n/a

Default SQL issue? - 11-11-2004 , 10:03 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

Thanks

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: SQL issue? - 11-11-2004 , 02:23 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


"Steve" <Steve (AT) discussions (DOT) microsoft.com> wrote

Quote:
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

Thanks



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.