Forum Replies Created

Viewing 15 posts - 5,296 through 5,310 (of 7,613 total)

  • RE: SQL choosing to use the worst possible index

    ricardo_chicas (3/16/2015)


    If I let the query run forever since it is scanning the whole table

    Hmm, isn't it scanning the nonclustered index rather than the whole table (clustered index)?

    Yeah just 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: Assitance in Union and Groups

    shezi (3/16/2015)


    ScottPletcher (3/16/2015)


    ...

    ORDER BY CASE WHEN pr.hours > 0 THEN 1 ELSE 2 END, Name

    Excellent.

    One final Question. The Employee table also has status. Active or Terminated. I 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".

  • RE: Assitance in Union and Groups

    Forgot Quote, see next post.

    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: Assitance in Union and Groups

    ORDER BY CASE WHEN pr.hours > 0 THEN 1 ELSE 2 END, Name

    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: Teasing apart a bit-field and storing the results in table rows

    Yep; much safer to use "> 0" rather than checking for the specific bit value 🙂

    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: What was the previous value

    Quirky update requires a clustered index that conforms to the computation being done.

    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 choosing to use the worst possible index

    I have the same concerns. SQL should be better at using the clustered index when it applies ... we went to the trouble to get the best clustered index...

    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: Assitance in Union and Groups

    I wasn't sure which table "valid_payroll" is in, so I guessed "Employee". If it's not, adjust the code accordingly. Btw, always use a table alias on every column...

    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: Data types and row size question

    Dan121 (3/16/2015)


    Scott, my concern is a size of a row. As Grant said UNIQUEIDENTIFIER is 16 bytes. if I have 503 columns with datatype 'UNIQUEIDENTIFIER' and rows are empty, will...

    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: Data types and row size question

    Let me point out that using a char-based column for a date is a very bad idea. Not only does it take more space but it will get garbage...

    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: Second Friday of every month

    Here's the code with the tally table built in as a derived table rather than a CTE.

    Note that we need an actual date computation to compute the first desired Friday...

    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: Second Friday of every month

    First, let's note that we need an actual date computation only for the first Friday. For the subsequent Fridays, we can simply add 7 more days.

    Note: 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: Separate Identity key and CI

    TryingToLearn (3/12/2015)

    It has one column( identity column) as the PK and...

    It has another column is used as CI

    Is there ever a benefit to this approach?

    Yes; indeed, that 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".

  • RE: Issue of retrieving same identity column value by multiple users

    Edit: Bolded mods to original code.

    BEGIN TRANSACTION

    DECLARE @DEPTNBR BIGINT

    SELECT TOP (1) @DEPTNBR = DEPTNBR

    FROM DEPARTMENT_DETAILS WITH (UPDLOCK,READPAST)

    WHERE STATUS = 1

    UPDATE DEPARTMENT_DETAILS

    SET STATUS = 0

    WHERE DEPTNBR =...

    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: Changing Order by

    CASE @Sort_Sel

    WHEN 'Resource' THEN R.RESCODE

    ELSE RIGHT(REPLICATE('0', 10) + CAST(D3.DATEID AS varchar(10)), 10)

    END ASC

    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,296 through 5,310 (of 7,613 total)