Solved

SQL Stuff Remove Trailing Character?

Posted on 2014-02-17
2
186 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
2 Comments
 
LVL 16

Accepted Solution

by:
Surendra Nath earned 400 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

932 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

11 Experts available now in Live!

Get 1:1 Help Now