Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Server error - Cannot call methods on nchar.

Posted on 2011-04-25
5
Medium Priority
?
1,235 Views
Last Modified: 2012-05-11
This part of my select is causing the 'Cannot call methods on nchar':
publishers.Percentage.TRIM()

How can I trim this field?
0
Comment
Question by:JT_SIRO
  • 2
  • 2
5 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 35463053
trim(publishers.Percentage)
Columns are no objects you can apply methods to. You have to use functions with columns as arguments.
0
 
LVL 19

Accepted Solution

by:
elimesika earned 252 total points
ID: 35463067
Use this
LTRIM(RTRIM(publishers.Percentage))

Open in new window

0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 248 total points
ID: 35463103
Blimey, yes, there is no TRIM, only LTRIM and RTRIM.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35464299
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 35464301
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

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

810 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