Forum Replies Created

Viewing 15 posts - 766 through 780 (of 827 total)

  • 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...

  • RE: T-SQL

    David_Simpson (11/17/2009)


    I did not even bother to try and analyze the queries, once I read that the GETDATE() function was executed 4 different times, the only possible answer was false...

  • RE: T-SQL

    Nice question: so, we could see the time zone of every user. 😀

    I live in Italy +1 hour.

    2009-11-16 11:42:01.793Monday

    2009-11-16 11:42:01.793Monday

    2009-11-16 10:42:01.793Monday

    2009-11-16 10:42:01.793Monday

    Ciao Ciao

  • RE: ISNULL

    Noel McKinney (11/3/2009)


    This is the main reason I make it a habit to use COALESCE rather than ISNULL unless there's a reason I need the behavior of ISNULL.

    I prefer ISNULL...

  • RE: ISNULL

    From BOL:

    Return Types

    Returns the same type as check_expression.

    In this case, a cast from varchar(12) to varchar(10)

  • RE: Identity Crisis

    San-847017 (10/28/2009)


    I always increment identity column with default value.

    I used a seed = 1 and an increment of 5 and in another table seed = 2 and an increment of...

  • RE: Concatenating Rows

    Min-437192 (10/18/2009)


    Yours is pretty cool, but what do I need to modify if I want to get rid of duplicates? 🙂

    Simply add DISTINCT clause.

    create table fruit(name varchar(20))

    insert into...

  • RE: Concatenating Rows

    msam77-503326 (10/15/2009)


    Below is simple sql that does that

    declare @res varchar(Max)

    select @res = coalesce(@res + ',', '') + [name]

    from

    (

    select 'Apple' as...

  • RE: Concatenating Rows

    declare @l varchar(max)

    ,@comma varchar(2)

    set @l = ''

    set @comma = ''

    select @l = @l + @comma + name

    ,@comma = ', '

    from

    ...

  • RE: T-SQL 2008

    Mighty (10/1/2009)


    I'm of the opinion that the answer(s) are incorrect.

    CUBE and ROLLUP where already available in SQL Server 2005, so they were not introduced with SQL Server 2008.

    CUBE and ROLLUP...

Viewing 15 posts - 766 through 780 (of 827 total)