• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1256
  • Last Modified:

SQL Server error - Cannot call methods on nchar.

This part of my select is causing the 'Cannot call methods on nchar':
publishers.Percentage.TRIM()

How can I trim this field?
0
JT_SIRO
Asked:
JT_SIRO
  • 2
  • 2
2 Solutions
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
trim(publishers.Percentage)
Columns are no objects you can apply methods to. You have to use functions with columns as arguments.
0
 
elimesikaCommented:
Use this
LTRIM(RTRIM(publishers.Percentage))

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Blimey, yes, there is no TRIM, only LTRIM and RTRIM.
0
 
Anthony PerkinsCommented:
The author is refering to the Trim method in .NET and not T-SQL.  Having said that, nchar by definition will always have trailing spaces at the end.  If you do not want that, then you will have to change the data type to nvarchar.
0
 
Anthony PerkinsCommented:
Nevermind.  It looks like I am the one that misread that they are in fact trying to use T-SQL.  Sorry for the confusion.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now