SQL Server Forums
Profile | Register | 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
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Brittney10
Posting Yak Master

USA
153 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
52325 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  
 New 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.03 seconds. Powered By: Snitz Forums 2000