Forum Replies Created

Viewing 15 posts - 76 through 90 (of 7,612 total)

  • Reply To: What is the best index strategy for a table that gets truncated?

    I'd suggest the clustered index on ( trade_date, symbol ) and not the other way around.  You want the clus key to be unique, so, if it's not, you'll 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".

  • Reply To: Compare rows within the same table

    The TaskNames would have to be contiguous for that method to work.  I wanted to also handle some other TaskName appearing between "Distribute" and "Print", just in case.

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

  • Reply To: Compare rows within the same table

    SELECT JobID
    FROM dbo.tblPrintTask
    GROUP BY JobID
    HAVING MAX(CASE WHEN TaskName = 'Distribute' THEN TaskID END) <
    MAX(CASE WHEN TaskName = 'Print' THEN TaskID END)

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

  • Reply To: A Design Question using a fictious example

    (page bump 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".

  • Reply To: A Design Question using a fictious example

    You could easily have an order of magnitude more rows in SG table than in T, and if you have a phone app waiting for the response, I would still...

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

  • Reply To: Best Clustered Index Configuration for Partitioned Multi-Tenant Table with RLS

    Nice.

    Also, you don't have to change the FKs in other tables if you need one for just ID.  Instead, just add a unqiue nonclus index on ( ID ); 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".

  • Reply To: A Design Question using a fictious example

    > What difference the client is a phone? <<

    Because to determine all the Tests that haven't been fully graded could require scanning a very large number of StudentGrade rows.

    If, instead,...

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

  • Reply To: A Design Question using a fictious example

    I would use option 2 in this case.  The safest way to set the flag consistently accurately is to use a trigger on the StudentsGrade 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".

  • Reply To: How much transaction logs generated by hourly/daily

    SQL captures the size of backups in table msdb.dbo.backupset.  Thus, you can query that table to add up total space used for backups.

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

  • Reply To: Pivot Help

    You could do as below.  You can't really GROUP BY ID, because that would separate the Small, Medium and Large into separate rows.

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

  • Reply To: Fill in missing hours for each VisitID during the day

    How is one to know when it's, say, 8AM or 9AM, and the last entry for a person was at 2AM, whether future entries were missed or the person is...

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

  • Reply To: Table Delete

    IF you're on Enterprise Edition, you can do an online build of an index for SpoolStartDt.  Then you can use that index to do the DELETEs.  If you're not on...

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

  • Reply To: Fill in missing hours for each VisitID during the day

    I haven't ultra-tuned this, but see if it gives you the correct results.

    ;WITH
    cte_tally10 AS (
    SELECT * FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) AS numbers(number)
    ),
    cte_tally_hrs 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".

  • Reply To: How to write this query?

    Maybe?:

    SELECT SYMBOL1, SYMBOL2
    FROM (
    SELECT SYMBOL1, ROW_NUMBER() OVER(ORDER BY SYMBOL1) AS row_num_1
    FROM #STOCKS1 S1
    WHERE NOT EXISTS(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".

  • Reply To: Best Clustered Index Configuration for Partitioned Multi-Tenant Table with RLS

    Since it's not an index seek, partitioning should still help the query by reducing the number of pages it has to search.  Once again, verify that by looking at 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 - 76 through 90 (of 7,612 total)