Blank space in the end of a nvarchar field

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.

Who is Participating?
Raja Jegan RConnect With a Mentor SQL Server DBA & ArchitectCommented:
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.
Guy Hengel [angelIII / a3]Billing EngineerCommented:
use nvarchar instead of nchar.
PapoteAuthor Commented:
OOps... Thanks.
Was using trim() as a fix. But completely forgot about nvarchar.
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.

All Courses

From novice to tech pro — start learning today.