Forum Replies Created

Viewing 15 posts - 16 through 30 (of 7,612 total)

  • Reply To: Looking for help with SQL statement

    I identified the changes I made to the original code using /*--<<--*/ on/around them.  This code should also perform better.

    SELECT
    sa.partid AS ALLOC_Part,
    sa.quantity,
    sa.ordertype,
    sa.worksorderid,
    sa.reference,
    sa.stockvalue,
    apm.partdesc,
    soi.orderid,
    soi.itemnumber,
    soi.partid AS SOI_Part,
    so.traderid,
    t.name,
    u.name As SalesRep,
    sub.Max_Batchvalue 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: Select @ for different fields

    You could also use Brian Gale's approach and use a proc to generate all the code for you.  Personally I would stick with dynamic SQL, but the other is an...

    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: Columnstore index question

    Columnstore won't gain you much (other than perhaps some disk space) since you are reading all the columns.  Personally, I would just use page compression.

    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: Columnstore index question

    Absolutely agree with analyzing page compression for the table.  It could be a huge help.  You can use:

    EXEC sys.sp_estimate_data_compression_savings 'dbo', 'table_name', NULL, NULL, 'PAGE'

    As  you noted, the nonclus index 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: Varchar(max) to lines

    I thought it was more complicated than that because a CHAR(13) should also count as a "space" as far as splitting words?!  Perhaps not, I guess it depends on exactly...

    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: Determining the Updated Columns

    IF UPDATE(CreditLimit)

    That approach seems preferable to me, unless you really have to use COLUMNS_UPDATED()

    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: Replace calculation in cursor with set based logic

    If the quirky UPDATE works, can you modify the original table to include the new calculated column?

    Let me ask: once a value has been calc'd, would it ever change?  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".

  • Reply To: continuous membership

    Please provide data in usable format: CREATE TABLE and INSERT statment(s).  That is way more useful to us than a "picture" of data.

    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: SQL Query Performance with Left Join

    Would need to see row counts to better understand the query.

    How is the Departments table clustered?  In general, again without knowing any details at this point, DepartmentID first followed by...

    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: SQL Query Performance with Left Join

    If the condition is on a LEF T JOIN, moving it to the WHERE will effectively convert the LEFT JOIN to an INNER JOIN.

    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 do you keep track of the purpose for SQL Logins?

    I use a table.  (Longtime DBA, so that comes naturally to me.)

    Basically, you need a table for the passwords, anyway, right?  Of course the table's encrypted and in a restricted...

    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: Why would using a variable vs Hard Value impact a Query's Performance

    SQL Server can maintain statistics that "tell" it how many rows are in given ranges of key data (histogram data).  For hard-coded, SQL can of course then pick a plan...

    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: Find all records in a table whose values when summed up will equal another value

    My function by default returns all matches, but you have options to prioritize fewer rows matching or more rows matching.

    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: Find all records in a table whose values when summed up will equal another value

    I have a function that does that.  It could also return 400 and (either) 600.  You'd have to specify how to pick one over the other.

    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: Migration related issue

    Make sure statistics for all large tables are updated.

    Review query plans to check for potential performance issues.

     

    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 - 16 through 30 (of 7,612 total)