Solved

Replacing the Last Three Characters

Posted on 1998-09-14
1
156 Views
Last Modified: 2010-03-19
In a stored procedure, a parameter @input is passed that contains '.htm' on the end.  In the sp I would like to replace the 'htm' with 'doc' and use it as the value of another input.
Is it possible to replace these characters?  They would always be on the end although the beginning of the parameter may contain 'htm' as well.  But I would want to replace the ending characters.
Thank you.
0
Comment
Question by:jgcarmich
1 Comment
 
LVL 10

Accepted Solution

by:
bret earned 100 total points
ID: 1090034
This will replace the last 4 characters of a string with ".doc":

select @input = stuff(@input, char_length(@input)-3,4,".doc")
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now