Solved

Replacing the Last Three Characters

Posted on 1998-09-14
1
157 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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 extract information from SQL Server on Database, Connection and Server properties

862 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

23 Experts available now in Live!

Get 1:1 Help Now