Forum Replies Created

Viewing 15 posts - 3,211 through 3,225 (of 7,619 total)

  • RE: Order of Clustered Index

    Mike Scalise - Friday, August 24, 2018 11:38 AM

    So, let's say I have a heap with the same structure as 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: Count the Number of Weekend Days between Two Dates

    For final prod code, I'd probably make a couple of other minor adjustments to make the code more inherently clear.  I'm a firm believer in self-documenting code, including clear variable...

    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: Order of Clustered Index

    SQL calls it a "uniquifier", not a "row id".  The assignment is completely arbitrary -- and totally meaningless to you.  If you're worried about getting "Abigail" Smith returned before "John"...

    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: Count the Number of Weekend Days between Two Dates

    There's no need for any tally table nor recursion.  A simple mathematical calc is enough.  I'm almost sure this is it, although I'm extremely busy and haven't fully tested it...

    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: Any way to reduce the execution time for 8mil + rows table with cross join

    Cool2018 - Thursday, August 23, 2018 2:34 AM

    Dear ScottPletcher,

    Yes. We need every match from Table_B to Table_A. We need to list every...

    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: Enforce Unique Constraint Across Two Tables

    David Moutray - Wednesday, August 22, 2018 7:06 PM

    You can do this using triggers.  As I mentioned in an earlier reply, 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: Enforce Unique Constraint Across Two Tables

    andycadley - Wednesday, August 22, 2018 12:02 PM

    ScottPletcher - Wednesday, August 22, 2018 9:38 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: Enforce Unique Constraint Across Two Tables

    A standard "AFTER" trigger will work.  Keep in mind that the trigger does not have to be "all or nothing": it can let good INSERTs/UPDATEs apply and only reverse 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".

  • RE: Enforce Unique Constraint Across Two Tables

    So how does that constraint prevent a custom tag from being the same as a standard tag?

    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: Enforce Unique Constraint Across Two Tables

    Whether you use a single Tag table or not, a trigger would still be much easier than a constraint.  Why do you not want to even consider a trigger?

    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: Will temp tables be dropped when Transaction commits?

    A COMMIT will not drop the temp table.  You need to drop it yourself.

    A ROLLBACK will drop a temp table if it was created within the transaction, but...

    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: Any way to reduce the execution time for 8mil + rows table with cross join

    Do you really want every match from Table_B to Table_A or only the most relevant match?  If you want to list every role, then this join will always be very...

    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 can I efficiently process large amounts of data in a function without a table variable

    Since you mentioned performance specifically, this might perform better:


    Select Count(Distinct HB.AbillNo) AS AbillNo
    FROM HB WITH (NOLOCK)
    Where HB.st = @StatusCode And
        Exists(

    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 ColumnStore Index not performing as expected vs Clustered row store?

    Did you partition the columnstore clustered index on posted delivery date also?  That would make sense if it was best to cluster the row store on that column.  It's important...

    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: average value before and after a point in time **without** using a union all

    "AVERAGE" isn't a SQL Server function, afaik.  It seems easy enough to get the result in SQL Server, but I'm not sure that would help you.

    Do you want...

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