Forum Replies Created

Viewing 15 posts - 3,316 through 3,330 (of 7,615 total)

  • RE: Violation of Primary Key Contraint

    To fix the immediate problem, try running:

    DBCC CHECKIDENT ('dbo.CmEvent', RESEED, 55845910)

    Better yet, rid yourself of the foolish and damaging myth that all tables should be clustered...

    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: Top 2 records with range

    ranitb - Wednesday, June 20, 2018 5:21 AM

    Does this help ?

    select top 2 *
    from (
        select max(u.iduser) iduser, max(u.score)...

    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: Getting suggestion for non-clustered index on a table with a clustered columnstore index (2016) -- need to understand how they relate

    As with any nonclus index, SQL estimating that too many pages will be needed from the nonclus index causes SQL to drop back to just scanning the main table.  I...

    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: Clustered PK perf -

    Chris Harshman - Tuesday, June 19, 2018 3:16 PM

    ranitb - Tuesday, June 19, 2018 8:27 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: Clustered PK perf -

    ranitb - Tuesday, June 19, 2018 12:58 PM

    You really should strongly consider defining the clus index before loading the table if at all possible
    >...

    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: Getting suggestion for non-clustered index on a table with a clustered columnstore index (2016) -- need to understand how they relate

    For the CCI, SQL will effectively have to scan all the rows for every query.  If you can a nonclus index, SQL may be able to just do lookups to...

    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: Long running query

    Agree with Luis, except even more strongly:
    We must see the DDL for the tables, including all indexes.
    It would also be nice to see usage stats for those indexes,...

    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: SARGability of query

    Also, consider clustering dbo.MyTable on (ValidUntil, CreatedOn) or adding ValidUntil to the nonclus index. [You don't have to cluster tables by identity, and it can actually be quite harmful to...

    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: Joining a large table to itself....better ideas?

    xsevensinzx - Tuesday, June 19, 2018 6:01 AM

    Jeff Moden - Tuesday, June 19, 2018 1:06 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: Clustered PK perf -

    If you (almost) always join on all the keys, then yes, cluster on all of them.

    You really should strongly consider defining the clus index before loading the table...

    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: Joining a large table to itself....better ideas?

    Given that a matched pickup and dropoff won't change in the future, when a dropoff gets entered, have a trigger link it to its pickup (store the pickup key(s) in...

    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: Return last amount larger than 0

    I'd check column separately rather than adding them, just in case negative amounts could appear now, or somehow do appear later:

    WHERE CE.CLOSING_CREDITS <> 0 AND CE.CLOSING_DEBITS <> 0

    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: Friday Fun - Excel Formula to SQL Functions

    Also, you want to avoid BETWEEN when dealing with dates / times.
    I have heard this often but I have never seen any proof as to why. I 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: Top 2 records with range


    SELECT TOP (2) IDUser, Score, Name
    FROM (
      SELECT U.IDUser, U.Score, U.RecordDt, S2.Name,
          ROW_NUMBER() OVER(PARTITION BY U.IDUser, S2.Name ORDER BY U.RecordDt DESC) 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: Friday Fun - Excel Formula to SQL Functions

    I think something like below is much easier to follow.  Also, you want to avoid BETWEEN when dealing with dates / times.

    I can't tell for sure if 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,316 through 3,330 (of 7,615 total)