From: Michael C on
The first returns an empty string as expected but the second is null. Is
this a bug or feature?

SELECT RIGHT('ABC', 0)
SELECT RIGHT(CAST('ABC' AS VARCHAR(MAX)), 0)

Cheers,
Michael


From: John Bell on
On Tue, 30 Mar 2010 16:35:02 +1100, "Michael C" <mike(a)nospam.com>
wrote:

>The first returns an empty string as expected but the second is null. Is
>this a bug or feature?
>
>SELECT RIGHT('ABC', 0)
>SELECT RIGHT(CAST('ABC' AS VARCHAR(MAX)), 0)
>
>Cheers,
>Michael
>

You don't say which version you are on, but I get varchar returned for
all of these, which is expected.

Microsoft SQL Server 2008 (SP1) - 10.0.2531.0

John
From: Michael C on
"John Bell" <jbellnewsposts(a)hotmail.com> wrote in message
news:nb53r5tuqnu2mh7m41rgtc03vlg9l51iii(a)4ax.com...
> You don't say which version you are on, but I get varchar returned for
> all of these, which is expected.
>
> Microsoft SQL Server 2008 (SP1) - 10.0.2531.0

I'm using 2005 and do get varchar as well, except that the varchar is null
in the second case but zero length in the first.

Michael


From: Tom Cooper on
In SQL 2005 SP3 (9.00.4053), I get NULL
In SQL 2008 SP1 (10.00.2531), I get the empty string.

So my guess is that it is a bug and they fixed it.

Tom

"Michael C" <mike(a)nospam.com> wrote in message
news:uCI4dE9zKHA.4656(a)TK2MSFTNGP05.phx.gbl...
> "John Bell" <jbellnewsposts(a)hotmail.com> wrote in message
> news:nb53r5tuqnu2mh7m41rgtc03vlg9l51iii(a)4ax.com...
>> You don't say which version you are on, but I get varchar returned for
>> all of these, which is expected.
>>
>> Microsoft SQL Server 2008 (SP1) - 10.0.2531.0
>
> I'm using 2005 and do get varchar as well, except that the varchar is null
> in the second case but zero length in the first.
>
> Michael
>

From: John Bell on
On Tue, 30 Mar 2010 02:34:01 -0400, "Tom Cooper"
<tomcooper(a)comcast.net> wrote:

>In SQL 2005 SP3 (9.00.4053), I get NULL
>In SQL 2008 SP1 (10.00.2531), I get the empty string.
>
>So my guess is that it is a bug and they fixed it.
>
>Tom
>
>"Michael C" <mike(a)nospam.com> wrote in message
>news:uCI4dE9zKHA.4656(a)TK2MSFTNGP05.phx.gbl...
>> "John Bell" <jbellnewsposts(a)hotmail.com> wrote in message
>> news:nb53r5tuqnu2mh7m41rgtc03vlg9l51iii(a)4ax.com...
>>> You don't say which version you are on, but I get varchar returned for
>>> all of these, which is expected.
>>>
>>> Microsoft SQL Server 2008 (SP1) - 10.0.2531.0
>>
>> I'm using 2005 and do get varchar as well, except that the varchar is null
>> in the second case but zero length in the first.
>>
>> Michael
>>

Or a feature in 2005 that changed behaviour in 2008!!!! :)

John
 |  Next  |  Last
Pages: 1 2
Prev: Hash Match best?
Next: Optimizing queries with isnull