Forum Replies Created

Viewing 15 posts - 2,881 through 2,895 (of 7,619 total)

  • Reply To: New to SQL, easy question

    You must add an ORDER BY clause to the query to get the rows to be in a specific order. But, the ORDER BY must also be in a...

    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 and Unpivot

    For clarification, a SQL column does not have to be all the same type: SQL has a type of sql_variant that is designed to handle different data types in 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".

  • Reply To: Using the OUTPUT CLAUSE in a INSERT statement.

    You can only put columns in the OUTPUT clause from the INSERTED and DELETED table(s), if/when each is present.

    Sadly, you can't use any column from any input in the query,...

    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: Week Number with custom dates


    ;WITH
    cteCalcBaseDates AS (
      SELECT DATEADD(MONTH, 7 - CASE WHEN MONTH(GETDATE()) < 8 THEN 12 ELSE 0 END,
      DATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()), 0)) AS Aug01,

    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: Using SUM OVER without an Order by

    The GROUP BY Entry Num should be enough:


    SELECT H.Customs_Entry_Num,
      MAX(h.Total_MPF) AS Total_MPF,
      SUM(L.MPF) AS Line_Sum
    FROM ADHOC.ATS_ESH H
    INNER JOIN ADHOC.ATS_ESL...

    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: Insert to Clustered Index

    Jim-S - Thursday, March 28, 2019 4:13 AM

    Jeff Moden - Wednesday, March 27, 2019 1:28 PM

    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: Horrible performance using sys.dm_os_performance_counters

    Are your CPUs really busy on that server for some reason?

    In my case, I have lots of free CPU, it's I/O that's restraining my system perf.

    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: Horrible performance using sys.dm_os_performance_counters

    PatLap - Wednesday, March 27, 2019 1:39 PM

    Got 78sec CPU time with COUNT and MAXDOP 1.
    The view returns around 11 millions rows. ...

    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: Horrible performance using sys.dm_os_performance_counters

    Wow, that seems way long for only 38 dbs.

    Force SQL to not parallelize the query, and see how that runs:

    SELECT
    DB_NAME(database_id) AS db_name,
    COUNT(*) / 128.0...

    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: Improve performance of a query by milliseconds. Should I loop the query to extrapolate the stats ?

    How is the underlying table clustered?

    What the most common WHERE conditions used when you read this table?

    The best, most complete solution overall is to best cluster...

    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: Horrible performance using sys.dm_os_performance_counters

    I did get less execution time cost using COUNT() rather than COUNT_BIG():

    SELECT
    DB_NAME(database_id) AS db_name,
    COUNT(*) / 128.0 AS buffer_pool_size_mb
    FROM sys.dm_os_buffer_descriptors WITH (NOLOCK)
    WHERE database_id <> 32767...

    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: deleting duplicates, even though different key values

    briancampbellmcad - Tuesday, March 26, 2019 11:47 AM

    ScottPletcher - Tuesday, March 26, 2019 11:39 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: deleting duplicates, even though different key values

    Yes.


    ;WITH cte_dups AS (
        SELECT *, ROW_NUMBER() OVER(PARTITION BY name ORDER BY id DESC) AS row_num /* keep the HIGHEST/LAST id */
        FROM...

    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: Problem using CTE

    Try it this way:


    SELECT *
    FROM (
      SELECT Sequence#, Member#, Group#
      WHERE Group# = 'PP0018'
    ) AS iq1
    WHERE Sequence# <> 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".

Viewing 15 posts - 2,881 through 2,895 (of 7,619 total)