Solved

Replacing the Last Three Characters

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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

808 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