Solved

SQL Stuff Remove Trailing Character?

Posted on 2014-02-17
2
188 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

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
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…

770 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