Forum Replies Created

Viewing 15 posts - 1,936 through 1,950 (of 7,613 total)

  • Reply To: Do we need to include a clustered index in a non-clustered index?

    Yes, it is very important here, to ensure that the nonclus index key is unique.

    And, besides, all clustered index key column(s) will always be added to every nonclus index whether...

    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: verifying procedure with data entered

    I changed to using descriptive variable names.  And I added some debugging displays to help you work through any issues.  The sample number you provided is failing the test, 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".

  • Reply To: Do we need to include a clustered index in a non-clustered index?

    Make the nonclus index UNIQUE yourself, don't force SQL to do it for you.  This is important for best performance.

    And, yes, you should include the DateDeleted in the index.  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".

  • Reply To: Optimal way to record a row as "needing something done" to it

    I don't think the current method is a bad approach.

    You can use a filtered index to identify the rows needing recalculated.

    IF the calcs were easy, I guess you could put...

    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: Lookup and insert into column without dynamic SQL?

    Are you genuinely on SQL 2016 or higher?

    If so, I think CHOOSE should save you a lot of coding here.

    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 find index usage by stored procedure?

    No.  SQL doesn't really care which proc is using the index, and even trying to capture that kind of data about index usage would be huge overhead.  Indexes need tuned...

    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: Accessing a RESTORING database for test refresh

    Do you pre-restore the full backup each time to speed up the next restore? (Assuming you have the disk space available -- and if not, you can get the space...

    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: @@TRANCOUNT = 2?

    @@TRANCOUNT itself is fine, I think.  Does UPDATE increment and decrement @@TRANCOUNT as it processes?!

    CREATE TABLE #foo (i INT NOT NULL);
    INSERT INTO #foo(i) VALUES (0);
    SET NOCOUNT ON;

    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: Accessing a RESTORING database for test refresh

    How large is the log file?  The disk area for a log file must be preformatted, whereas data files do not (assuming you have IFI activated, which is standard now).

    Do...

    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: Opaque Encryption - with No Views, or Special SQL

    You would do that with view(s).  The ENCRYPT / DECRYPT would be only within the view(s).

    The users don't have to query anything different, as you can make the original 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: Looking for tips on Optimizing

    You're welcome!  I'm glad it helped.  Interesting q to play with.

    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: Looking for tips on Optimizing

    Maybe something like this?:


    SELECT Item, Date1, Date2, Date3
    FROM @headerTable
    UNION ALL
    SELECT
    Item,
    CAST(MAX(CASE WHEN week# = 1 THEN Quantity END) AS varchar(10)),
    ...

    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: Looking for tips on Optimizing

    Yeah, this can be definitely done in a standard SELECT.

    Do you want to show only the weeks that had a match or do you want to show all 52 weeks,...

    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: Lookup and insert into column without dynamic SQL?

    I'm confused about a couple of things.

    First, why do you only want to INSERT "field3" (really column3)?

    There's no link or association to #FieldValues.  Surely there must be some columns missing...

    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: Is the order of the columns in the NC index important

    SQL provide missing index info that you can use to help determine whether you need other index(es) or not, or even whether you need to change the clustered index 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".

Viewing 15 posts - 1,936 through 1,950 (of 7,613 total)