Forum Replies Created

Viewing 15 posts - 5,011 through 5,025 (of 7,619 total)

  • RE: Query help - pulling daily total from cumulative total

    You'll probably need to use ROW_NUMBER() for now:

    ;WITH CTE_sales AS (

    SELECT

    date_created, sales,

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need help on Scalar value Function

    Jeff Moden (6/26/2015)


    ScottPletcher (6/26/2015)


    Sean Lange (6/26/2015)


    ScottPletcher (6/25/2015)


    GilaMonster (6/25/2015)


    Nolock hints, do you know what they do? (hint, they don't make queries faster)

    Why does everyone keep repeating that?

    Scott you have been...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need help on Scalar value Function

    Sean Lange (6/26/2015)


    ScottPletcher (6/25/2015)


    GilaMonster (6/25/2015)


    Nolock hints, do you know what they do? (hint, they don't make queries faster)

    Why does everyone keep repeating that?

    Scott you have been around sql long...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need help on Scalar value Function

    Jeff Moden (6/25/2015)


    ScottPletcher (6/25/2015)


    sgmunson (6/25/2015)


    ScottPletcher (6/25/2015)


    GilaMonster (6/25/2015)


    Nolock hints, do you know what they do? (hint, they don't make queries faster)

    Why does everyone keep repeating that? Of course NOLOCK hints...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need help on Scalar value Function

    sgmunson (6/25/2015)


    ScottPletcher (6/25/2015)


    GilaMonster (6/25/2015)


    Nolock hints, do you know what they do? (hint, they don't make queries faster)

    Why does everyone keep repeating that? Of course NOLOCK hints make queries run...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: query about nulls

    sgmunson (6/25/2015)


    ScottPletcher (6/25/2015)


    I prefer this approach [Edit: Because of its clarity, and to avoid using functions in the WHERE clause, which should be avoided whenever (reasonably) possible]:

    WHERE

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: query about nulls

    I prefer this approach [Edit: Because of its clarity, and to avoid using functions in the WHERE clause, which should be avoided whenever (reasonably) possible]:

    WHERE

    (requirementGradYear...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: need help on Scalar value Function

    GilaMonster (6/25/2015)


    Nolock hints, do you know what they do? (hint, they don't make queries faster)

    Why does everyone keep repeating that? Of course NOLOCK hints make queries run faster, even...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Create table help?

    Select [C1] ,

    [C2] ,

    DATEADD(S, C3, '1970-01-01 00:00:00') AS [C3] ,

    [C4] ,

    [C5] ,

    [C6] ,

    [C7] ,

    [C8] ,

    [C112],

    [C675001003] ,

    [C812000101] ,

    [C875000000] ,

    [C875000001],

    [C875000002] ,

    [C875000003] ,

    [C875000004] ,

    [C875156000] ,

    [C875156001] ,

    [C875156002] ,

    [C875156005] ,

    [C875156006] ,

    [C875156007] ,

    [C875156003] ,

    [C875156004]...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Working around the lack of subquery support

    drew.allen (6/19/2015)


    By default, SQL Server joins tables in left-to-right order,

    I'm not sure it's safe to make that blanket statement. I think SQL will join in whatever order it deems...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Unable to run procedures with 'Execute as owner'

    Is the owning account a single user account? Or did it get changed into a group account or role?

    When you use "EXECUTE AS OWNER" the owner cannot be a...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Update or something else

    UPDATE Sales

    SET Sales.price = P.price

    FROM Sales

    CROSS APPLY (

    SELECT TOP (1) price

    FROM Price

    WHERE Sales.itemId = Price.itemId AND

    ...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Trigger for Update action without primary key

    That trigger is way too much overhead. The trigger itself cannot be dynamic. Instead, dynamic code should be used to generate a static trigger, which will need regenerated...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: CTE (?) or query help

    I created minimum sample data, which I've included after the main code. I assumed you have a table that has a list of IDs -- if not, just uncomment...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • RE: Cannot perform an aggregate function on an expression containing an aggregate or a subquery

    Please try this and see if it's right, or at least very close :-D. Btw, please add appropriate table aliases to all columns (scope_id, firstName (presumably CUS but not...

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

Viewing 15 posts - 5,011 through 5,025 (of 7,619 total)