Forum Replies Created

Viewing 15 posts - 3,001 through 3,015 (of 7,613 total)

  • RE: IF field exist in multiple dbs on server

    sebekkg - Wednesday, January 23, 2019 8:14 AM

    ScottPletcher - Wednesday, January 23, 2019 6:59 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: very slow select

    Jeff Moden - Wednesday, January 23, 2019 7:29 AM

    ScottPletcher - Tuesday, January 22, 2019 11:27 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: IF field exist in multiple dbs on server


    EXEC sp_MSforeachdb '
    IF LEN(''?'') = 9 AND RIGHT(''?'', 5) = ''_prod''
    BEGIN
        USE [?];
        IF EXISTS(SELECT 1 FROM sys.columns WHERE object_id =...

    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: very slow select

    Jeff Moden - Tuesday, January 22, 2019 10:57 AM

    ScottPletcher - Tuesday, January 22, 2019 10:02 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: Query tuning with conditional aggregation

    You need to either:

    Cluster the table by timestamp (if that's how you (almost) always query against the table)
    Or
    Create a non-clus index on (Timestamp) include (TagName, 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: very slow select

    You wouldn't typically want to cluster on status, since it tends to change.

    However, you'd almost certainly be better off clustering by PROPERTY_ID and /or SOURCE_ID in whatever order.  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".

  • RE: Performance Issue with Simple Query /Big Tables

    Quite right on the "out of memory" error.

    Overall, though, for best performance with far fewer total indexes:
    cluster the CHUB_S_CON_ADDR TABLE on ( CONTACT_ID, ROW_ID ).
    Add 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".

  • RE: User Defined Function for following scnario

    No need to use resources to recompute the string every time.

    Pre-generate all the strings and store them in a permanent table.  Then just pull out the row(s) you...

    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 Cross Apply with WHERE clause

    drew.allen - Tuesday, January 15, 2019 1:36 PM

    ScottPletcher - Tuesday, January 15, 2019 12:57 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: Which index will perform better

    Agree, a filtered index if possible.

    Then lock down the requirements.  If you need to delete all B = 1, whether the date is a future date or not...

    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 about using GROUP BY vs MAX() for a column that will only have one value

    It's usually more efficient to use MAX(), particularly for char columns.  GROUP BY for an extra char column requires sorting/hashing that is typically much more overhead.

    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 Cross Apply with WHERE clause

    A CROSS JOIN is good for this:


    SELECT o.OrderID, o.OrderPaid, o.TotalTaxes, o.OrderTotal,
        cy.CycleStartPlusOne, cy.CycleEndPlusOne
    FROM dbo.Orders o
    CROSS JOIN (
        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".

  • RE: Rank Table Sales Setup with Sale

    Your ranges have gaps: where would 500,000.50 fall?

    At any rate, something like:

    SELECT s.sales, ss.Nota
    FROM sales s
    LEFT OUTER JOIN sales_setup ss ON s.sales...

    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: formatting lost when copying from one table to another (Solved)

    Don't use that view; because:
    (1) it only returns 4000 chars, no matter how long the actual proc is.
    (2) INFORMATION_SCHEMA views run slowly and generate overhead that's not 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".

  • RE: Cross compare from within the same table.

    I'm still not 100% sure of your rules, but hopefully if needed you can adjust this to get what you need:


    SELECT
        jec.main, jec.sub,

    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 - 3,001 through 3,015 (of 7,613 total)