The Entertaining Sybase. What do LTRIM and RTRIM return?

I have been working with Sybase ASE for a year. And there is a lot of fun with this database and which would like to collect here. What do  LTRIM and RTRIM return in the query?

SELECT [Space R] = RTRIM(' '), [Space L] = LTRIM(' '),
       [Empty R] = RTRIM(''), [Empty L] = LTRIM('')

Guessed?

ASE Version:

SELECT @@VERSION

Adaptive Server Enterprise/15.0.3/EBF 17769 ESD#4/P/Sun_svr4/OS 5.8/ase1503/2768/64-bit/FBO/Thu Aug 26 15:08:16 2010

It returns all nulls!

 Space R     Space L     Empty R     Empty L
 ----------  ----------  ----------  ----------
 (null)         (null)         (null)          (null)

Probably this is because of Sybase treats strings differently. Sybase stores null strings as empty strings, and empty strings as one-whitespace strings.

Note: MS SQL works as I expected. It returns the empty strings for the query above. Looks sanely for me. The question is: who is insane here?

Advertisements
This entry was posted in Entertaining Sybase, Sybase. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s