|
-
Oct 7th, 2009, 01:14 PM
#9
Re: [SQL Server 2005] Mysterious problem with CASE statement
it prints with spaces which means CHAR type.
WHACK! NO! just because it has spaces doesn't make it a char type...
if you PRINT CONVERT( char(2), 'A') .... then yes, you get the space... since you've defined it to be 2 characters long....
VarChar is like String in VB... it is a VARiable CHARacter length .... CHAR is FIXED LENGTH... Like String*5 - so when you use the type Char(5) ... you're saying. this will be 5 characters long.... no more... no less... It is a fixed size. Since you can't have an empty char string, it fills it with spaces. the Char() function explicitly returns a Char type....
I'm not sure what you were expecting with those tests you ran... they return exactly what I would expect.
-tg
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|