how to trim values of xml attribute?

Rajesh Kumar Yadav 1 Reputation point
2023-11-10T10:13:01.1466667+00:00

Hi,

I want to trim @cotd

so is there any function which can do it.


		 SELECT LTRIM(RTRIM(R.C.value('@Name','nvarchar(100)'))) 
		        
		 FROM @xm.nodes('/test[ fn:lower-case(@cotd) !=""]') AS R(C) 
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
14,149 questions
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,950 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,612 questions
SQL Server Analysis Services
SQL Server Analysis Services
A Microsoft online analytical data engine used in decision support and business analytics, providing the analytical data for business reports and client applications such as Power BI, Excel, Reporting Services reports, and other data visualization tools.
1,297 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,665 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Javier Villegas 900 Reputation points MVP
    2023-11-10T14:13:07.0633333+00:00

    Note that Since SQL Server 2022 you can use TRIM

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.