Forum Replies Created

Viewing 15 posts - 3,016 through 3,030 (of 7,619 total)

  • RE: Which index will perform better

    Agree, a filtered index if possible.

    Then lock down the requirements.  If you need to delete all B = 1, whether the date is a future date or 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".

  • RE: Question about using GROUP BY vs MAX() for a column that will only have one value

    It's usually more efficient to use MAX(), particularly for char columns.  GROUP BY for an extra char column requires sorting/hashing that is typically much more overhead.

    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: Using Cross Apply with WHERE clause

    A CROSS JOIN is good for this:


    SELECT o.OrderID, o.OrderPaid, o.TotalTaxes, o.OrderTotal,
        cy.CycleStartPlusOne, cy.CycleEndPlusOne
    FROM dbo.Orders o
    CROSS JOIN (
        SELECT...

    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: Rank Table Sales Setup with Sale

    Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.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: formatting lost when copying from one table to another (Solved)

    Don't use that view; because:
    (1) it only returns 4000 chars, no matter how long the actual proc is.
    (2) INFORMATION_SCHEMA views run slowly and generate overhead that's not needed.

    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: Cross compare from within the same table.

    I'm still not 100% sure of your rules, but hopefully if needed you can adjust this to get what you need:


    SELECT
        jec.main, jec.sub,

    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: Select convert to 2 decimal places, comma, right aligned


    select
        right(space(12)+convert(varchar(20),cast([User_Info_Currency_1] as money),1), 12) as [Replacement Cost]
    from (
    values(
    523.88000),(
    60689.76000),(
    48860.26000),(
    77239.26000),(
    132227.26000),(
    65668.18000),(
    71523.34000)
    ) as EQSA0345(User_Info_Currency_1)

    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: SQL Optimization

    Reforrmat  the SSICat data and not the ep data, since there should be far fewer SSICat rows.

    How is the EncounterProc table clustered?

    Hopefully you don't actually need...

    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: how to do this join?


    SELECT
    b.Period AS B_Period,
    a1.Period AS A_period,
    a1.SomeValue
    FROM #TableB b
    OUTER APPLY (
        SELECT TOP (1) a.*
        FROM #TableA 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: Query Performance

    Jeff Moden - Wednesday, January 2, 2019 9:46 AM

    ScottPletcher - Wednesday, January 2, 2019 8:26 AM

    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 Performance

    Cluster the [SearchSuggest_QGram_tbl] on [nameCacheId] rather than on gram.

    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: Validate date stored as a string as a complete, valid date

    Jeff Moden - Monday, December 24, 2018 10:41 AM

    Scott In Sydney - Thursday, December 20, 2018...

    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: Validate date stored as a string as a complete, valid date


    SELECT s
        s2
        ,TRY_CAST(s2 AS DATE) AS ScottPDate
    FROM @t
    CROSS APPLY (
        SELECT LTRIM(RTRIM(s)) AS s1
    ) AS ca1
    CROSS...

    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: Implementing a trigger on a status change/insert rec to update a flag

    I'd add the standard "nocount" setting, but other than that it looks good:


    alter trigger trg_up_in_changeflag
    on example_table
    after update, insert

    as

    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: Error: Cannot insert duplicate key row in... a non-unique index?!

    Eric M Russell - Tuesday, December 18, 2018 3:37 PM

    After examining Query Store, I have determined the following update statement is the...

    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 - 3,016 through 3,030 (of 7,619 total)