Solved

SQL Stuff Remove Trailing Character?

Posted on 2014-02-17
2
184 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
Comment Utility
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
Comment Utility
thx
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

743 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

14 Experts available now in Live!

Get 1:1 Help Now