We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Blank space in the end of a nvarchar field

Medium Priority
Last Modified: 2012-05-06
I created a table in SQL Server 2005 and when I enter a string text in a field set to nchar(15) and allow nulls, it adds empty space at the end so to fill the 15 characters. Gives me a headache trying to compare.

Watch Question

Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

use nvarchar instead of nchar.
SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2019
If you use datatype as NChar, then it will pad up the empty values with empty space. But if you use datatype as Nvarchar empty spaces will be left and hence you will have only your data.

Hence if you use NChar, you have to trim your data and then use for join or comparison or you can use Nvarchar too.

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


OOps... Thanks.
Was using trim() as a fix. But completely forgot about nvarchar.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.