Solved

Replacing the Last Three Characters

Posted on 1998-09-14
1
161 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

734 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