[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 394
  • Last Modified:

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.

0
Papote
Asked:
Papote
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
use nvarchar instead of nchar.
0
 
Raja Jegan RSQL 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.
0
 
PapoteAuthor Commented:
OOps... Thanks.
Was using trim() as a fix. But completely forgot about nvarchar.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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