Re: why use CHAR.. _EVER_?
- From: "aaron.kempf@xxxxxxxxx" <aaron.kempf@xxxxxxxxx>
- Date: 3 Oct 2006 09:25:42 -0700
thanks; that is very helpful
-Aaron
Mike C# wrote:
<aaron.kempf@xxxxxxxxx> wrote in message
news:1159815989.569683.204390@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I just don't see the point in having 20 fields that are all varchar(50)
when they only hold data that is 10 characters long.
stuff like keys?
i personally think that all keys everywhere should always be an
integer-- or preferably smallint--
Shhhh. You could start a holy war with talk like that :) There are a lot
of folks who believe strictly, 100%, in Natural Keys - which are very often
character-based instead of numeric; much less INT or SMALLINT.
it just drives me crazy; i've noted some definite peculiarities
like i've got field1 = 'aaron ' stored in a table; if i search
using a query where field1 = 'aaron' it finds a match; is this
implicit?
SQL, by definition, ignores white-space at the end of CHAR data types. This
includes CHAR, VARCHAR, NCHAR, NVARCHAR, etc. To take your example further
you can put 'aaron ' in a CHAR variable and 'aaron' in a VARCHAR and
they will match as well.
does it automatically do a right trim on everything you do in a char
field?
I think the standard calls for adding extra padding to the search
expression, but the net result is the same.
i just dont understand why 'aaron' matches to 'aaron '
it just seems inconsistent the way that they do it.
It's a leftover from the days when all that was available was fixed-width
CHAR types. It actually is pretty handy since you don't have to RTRIM()
every column in search expressions, and extra space at the end of character
type data will not affect your results.
.
- References:
- why use CHAR.. _EVER_?
- From: dbahooker
- Re: why use CHAR.. _EVER_?
- From: Russ Rose
- Re: why use CHAR.. _EVER_?
- From: aaron.kempf@xxxxxxxxx
- Re: why use CHAR.. _EVER_?
- From: Mike C#
- why use CHAR.. _EVER_?
- Prev by Date: How to create a DB corruption (SQL Server 2005)
- Next by Date: Re: How to create a DB corruption (SQL Server 2005)
- Previous by thread: Re: why use CHAR.. _EVER_?
- Next by thread: DTS Help.
- Index(es):
Relevant Pages
|