how to trim values of xml attribute?

Rajesh Kumar Yadav 1 Reputation point


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.
11,635 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,642 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,328 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,209 questions
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,462 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Javier Villegas 725 Reputation points MVP

    Note that Since SQL Server 2022 you can use TRIM

    0 comments No comments