I need a table for bookkeeping all types in the data model. I don't have that many types but a fair deal of 'em. Ideally short descripive names would work well.
So I did this:
CREATE TABLE EntityType
(
EntityTypeID char(2) PRIMARY KEY,
EntityTypeName varchar(128) NOT NULL
)
And put some data into the table:
INSERT INTO EntityType VALUES ('A', 'Type1')
INSERT INTO EntityType VALUES ('B', 'Type2')
But that I can query like this baffles me:
DECLARE @pEntityType char(1)
SET @pEntityType = 'A'
SELECT ''''+EntityTypeID+'''', EntityTypeName
FROM EntityType
WHERE EntityTypeID = @pEntityType
The result yields 'A ', and there's whitespace in that literal.
My understanding is that there's an implicit conversion that's converting char(1) -> char(2)
I'm not complaining, but what's the rationale behind this?