Forum Replies Created

Viewing 15 posts - 751 through 765 (of 821 total)

  • RE: Finding the Correct Weekday Regardless of DateFirst

    This code is indipendent from datefirst:

    Monday is 0 and Sunday is 6

    SELECT cast(cast('20100215' as datetime) as int)%7

    SELECT cast(cast('20100216' as datetime) as int)%7

    SELECT cast(cast('20100217' as datetime) as int)%7

    SELECT cast(cast('20100218' as datetime)...

  • RE: Easy Error Trapping When Using xp_cmdshell

    create table XPCmdShellOutput (OutputLine varchar(1000), ID INT IDENTITY(1,1))

    Please add an identity column, so you can have output lines in the correct order

  • RE: Rowcount

    If one omits the set nocount on statement, then the results would be 1,1.

    This assert is wrong.

    The correct answer is 0,1, but the two statement should be the first in...

  • RE: Query cost

    Volumes of data returned from tables may vary (test or production database), so a well performing query may slow down or give an error.

    FROM BOL:

    Including an extremely large number...

  • RE: Replication

    My answer is correct, but it's luck!

    The text of the question is incomprehensible and the explanation is more and more incomprehensible.

  • RE: SELECT @local_variable

    If the SELECT statement returns no rows, the variable retains its present value. If expression is a scalar subquery that returns no value, the variable is set to NULL.

    That...

  • RE: How long is a NULL?

    The question is:

    it is a BUG?

    ... or it is by design?

    ... or both: it is a BUG by design!

    Try this:

    DECLARE @v-2 char(10)

    SET CONCAT_NULL_YIELDS_NULL ON

    SELECT ISNULL('abcd'+@v,'1234567890')

    RESULT: 1234567890

    This behavior is all right!

  • RE: How long is a NULL?

    Also a void string take 1 CHAR:

    SET CONCAT_NULL_YIELDS_NULL ON

    SELECT ISNULL('abcd'+''+null,'1234567890')

    Result: 123456

  • RE: Clustered Index Internals

    vk-kirov, I agree with you. Question and answer is incomprehensible!!!!

  • RE: Counting spaces

    rcavill (12/7/2009)


    You need the option

    Must declare the scalar variable "@Dec".

    When running on a Case Sensitive collation.

    Once that select statement on line 2 is adjusted then it would work.

    ------

    Robert

    Have good luck...

  • RE: Fun with Scale and Precision

    Explanation is in the note.

    Try to reduce the precision.

    SELECT CAST(cast(1.67574 as decimal(38,10)) / cast(10000 as decimal(38,10)) AS DECIMAL(38,10) ) conv_factor

    returns 0.0001670000

    SELECT CAST(cast(1.67574 as decimal(29,10)) / cast(10000 as decimal(29,10)) AS...

  • RE: Datetime precision

    SQLBOT (11/29/2009)


    Comments posted to this topic are about the item <A HREF="/questions/Datetime+Manipulation/68075/">Datetime precision</A>

    Thanks. After year and years working with sql, there always is something to learn.

  • RE: Variables, Nulls and Coalesce

    Rob Goddard (11/27/2009)


    does the optimizer spot this and skip all the variable assignments and just do the last one?

    All the variable assignments are done.

  • RE: Variables, Nulls and Coalesce

    Wouldn't you always get a row returned with the COUNT(*) aggregate? It might return 0 as the result but that still returns a row.

    That's true!

  • RE: Variables, Nulls and Coalesce

    WARN: If you use an aggregate function @a will be updated also if no row is returned

    [font="Arial"]SET NOCOUNT ON

    declare @vals table (iKey int, iValue int)

    insert into @vals (iKey, iValue)

    select...

Viewing 15 posts - 751 through 765 (of 821 total)