Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Replace
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brittney10
Posting Yak Master

USA
154 Posts

Posted - 02/19/2013 :  19:27:22  Show Profile  Reply with Quote
I need to do a find and replace on a file string. All of my files contain the word "Test" and i want to remove everything to right of "Test" and replace it with ".txt".

For example.

"My_File_Test_123434235.csv"

would become...

"My_File_Test.txt"

I'm using a variable to rename the file, so this has to be done in an expression.

Thanks for the help in advance.

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 02/20/2013 :  01:30:10  Show Profile  Reply with Quote
use expression like

(FINDSTRING("Test",YourColumn,1)>0 ? SUBSTRING(YourColumn,1,FINDSTRING("Test",YourColumn,1)+3) + ".txt" : YourColumn)

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000