Forum Replies Created

Viewing 15 posts - 1,771 through 1,785 (of 8,416 total)

  • RE: Question.. maybe a dumb one lol

    rjdpa2 (8/3/2011)


    thanks!! that helps a lot but it also requires me to change the compatibility level of the DB, which i can't really do. is there another alternative?

    Sure:

    SELECT

    ...

  • RE: Exists

    Tom.Thomson (8/3/2011)


    Except that quite often it does evaluate the expression - it's extremely inconsistent.

    Can't argue with the general sentiments there!

    In their defence, I would say that quite a number of...

  • RE: Exists

    OCTom (8/3/2011)


    [Is it simply inconsistency that the following returns an error?

    SELECT 'Test' WHERE EXISTS (SELECT LOG(0))

    As noted earlier, this returns an error instead of ignoring the select list of the...

  • RE: Exists

    Christian Buettner-167247 (8/3/2011)


    If you think these are strange, then what about this one?

    SELECT 'Test' WHERE EXISTS (SELECT LOG10(1/0))

    🙂

    That's my new favourite! :laugh:

  • RE: Exists

    marlon.seton (8/3/2011)


    I'm not convinced that EXPRESSION is not executed

    More complex subqueries do indeed need to be evaluated to determine if a row is produced or not - it's just subqueries...

  • RE: Exists

    Toreador (8/3/2011)


    So if Microsoft are correct to claim that this is by design, then presumably they would acknowledge all the counter-examples provided by SQLkiwi as bugs?

    Yes they have:

    http://connect.microsoft.com/SQLServer/feedback/details/649957/case-expression-evaluates-else-branch-at-compile-time

    All fixed in...

  • RE: Question.. maybe a dumb one lol

    DECLARE @Table TABLE

    (

    store_idINTEGER NOT NULL,

    visit_timeDATETIME NOT NULL,

    customer_idINTEGER NOT NULL

    )

    INSERT @Table

    (store_id, visit_time, customer_id)

    VALUES

    (1, '8/3/2011 8:02PM', 1),

    (1, '8/3/2011 8:41PM', 2),

    (2, '8/3/2011 8:31PM', 1),

    (2, '8/3/2011 9:01PM', 1)

    SELECT

    pvt.store_id,

    [8pm] = pvt.[20],

    [9pm] = pvt.[21]

    FROM

    (

    SELECT

    store_id,

    hr = DATEPART(HOUR,...

  • RE: case statement question

    Sean Lange (8/1/2011)


    WOW that is odd!!! The code is to evaluate the value of BusCalItemID and when it equals BusCalItemID then 0 else 1. That will always evaluate to 0....

  • RE: very slow query

    Ninja's_RGR'us (8/2/2011)


    The stats will correctly know that 1 and only 1 row or 0) can be returned so that can't possibly be the issue.

    Well technically it's not the statistics -...

  • RE: behaviour of LEN()

    The following pattern can be useful when you can't be sure whether the input string is Unicode or not:

    DECLARE @string VARCHAR(100) = ''

    DECLARE @string2 NVARCHAR(100) = N''

    SELECT DATALENGTH(@string) / ISNULL(NULLIF(DATALENGTH(LEFT(@string,...

  • RE: Exists

    deepak.a (8/2/2011)


    Even for the below statement also

    SELECT 'Test' WHERE EXISTS (SELECT SQRT(-1))

    Some more:

    SELECT 'Test' WHERE EXISTS (SELECT ACOS(PI()))

    SELECT 'Test' WHERE EXISTS (SELECT ASIN(PI()))

    SELECT 'Test' WHERE EXISTS (SELECT LOG10(0))

  • RE: Exists

    Good question, but try:

    SELECT 'Test' WHERE EXISTS (SELECT LOG(0))

    TSQL is not a model of consistency.

  • RE: DBCC INDEXDEFRAG

    sjimmo (8/2/2011)


    Not looking for empathy, and this is one of those points where we can respectably decline to agree.

    Of course. I'm first up to criticize a poor QotD (and...

  • RE: Are the posted questions getting worse?

    Ninja's_RGR'us (8/2/2011)


    So what's your #? :w00t:

    How would I know? I never call it. 😛

  • RE: Are the posted questions getting worse?

    Stefan Krzywicki (8/2/2011)


    Couldn't resist bragging?

    🙁

Viewing 15 posts - 1,771 through 1,785 (of 8,416 total)