Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Stuff Remove Trailing Character?

Posted on 2014-02-17
2
Medium Priority
?
200 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
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 the fundamental information of how to create a table.

610 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