?
Solved

SQL Stuff Remove Trailing Character?

Posted on 2014-02-17
2
Medium Priority
?
194 Views
Last Modified: 2014-02-21
I know how to remove a Leading char like so, just don't know how to remove a trailing char. Help...

Stuff ((
Select  '; ' + d.name
From Departments d
From XML Path(''), elements), 1, 1, ' ')
as Depts
0
Comment
Question by:WorknHardr
[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
2 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 1600 total points
ID: 39865731
for that you have to re-write the above query as below

declare @t VARCHAR(2000)
SET @T = (Select  '; ' + d.name
From Departments d
From XML Path(''), elements)

select stuff(@t,len(@t),1,'')

you just have to replace the 1,1,'' with the len(string),1,''.
0
 

Author Closing Comment

by:WorknHardr
ID: 39877762
thx
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

752 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