Forum Replies Created

Viewing 15 posts - 4,111 through 4,125 (of 7,613 total)

  • RE: Add column value depending on other value in same row

    My best guess is something like this:

    UPDATE sc

    SET column_x = ISNULL(sot1.value, '') + ISNULL(sot2.value, '') + ISNULL(sot3.value, '')

    FROM dbo.SaltoCardholders sc

    LEFT OUTER JOIN dbo.some_other_table1 sot1 ON sot1.lookup_col = sc.loc

    LEFT OUTER 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".

  • RE: How to improve the efficiency of a conditional join

    The most important thing is to:

    Cluster the dbo.FreightRate table on ( SourceKey, CompanyKey, PackingType ).

    But you could adjust the query slightly also:

    SELECT COALESCE(fr1.FreightRate, fr2.FreightRate, fr3.FreightRate, 0)

    FROM dbo.Sales s

    LEFT JOIN dbo.FreightRate...

    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: Backup database only if changes happen

    To be fair, the number of databases would have an impact here. I've got servers with hundreds (and hundreds) of dbs. Even small files add up to 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: How to use sp_msforeachdb to create multiple table in multiple databases

    drew.allen (10/4/2016)


    ScottPletcher (10/4/2016)


    Create a proc in the master db, beginning the name with "sp_", mark that proc as a system object, then use sp_MSforeachdb to run the proc 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".

  • RE: How to use sp_msforeachdb to create multiple table in multiple databases

    Create a proc in the master db, beginning the name with "sp_", mark that proc as a system object, then use sp_MSforeachdb to run the proc in the db(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: count every hour per day

    DECLARE @start_date datetime;

    DECLARE @end_date datetime;

    SET @start_date = '20010101';

    SET @end_date = '20010101 23:00';

    ;WITH tally10 AS (

    SELECT number FROM (VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) tally(number)

    ),

    tally1000 AS (

    SELECT ROW_NUMBER()...

    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: How to get the previous weeks data based on week ending

    Sorry, just now have time to follow up on this.

    CROSS APPLY (CA) really is a type of join, I'm just co-opting it here to assign names to values. 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: How to get the previous weeks data based on week ending

    I think messing with DATEFIRST when you don't absolutely have to is just asking for issues later. The CROSS APPLYs are used just to simplify the main SELECT list...

    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: Execution Plan Help. Enormous Increase in row count in plan

    thomashohner (9/30/2016)


    The clustered index issue is hard as these are staging tables and the method we use from change tracking is prone to duplicate inserts sometimes. Its far from ideal....

    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: Execution Plan Help. Enormous Increase in row count in plan

    thomashohner (9/30/2016)


    WOW, you have to be joking. 14 seconds row count on the money. Attached is the execution plan.

    Thank you both so very much. Holy molly :-D:-D

    Great, glad it...

    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: Execution Plan Help. Enormous Increase in row count in plan

    Try this:

    ...

    Ethnicity,

    MaritalStatus,

    ...

    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: Intentional Normalization Violation

    In this case, I think it's ok to add the current status to the Orders table, using an efficient, well-written trigger to maintain the status.

    However, the lookup of the current...

    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: Execution Plan Help. Enormous Increase in row count in plan

    I can't see any of the indexes, but perhaps you can combine the Lists lookups as below.

    Also, you'll probably get best performance by clustering the Lists table by ( Databasekey,...

    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 mdf files size

    ramana3327 (9/30/2016)


    Will there any performance impact by reducing the mdf file size?

    Probably not, if the space was never used.

    The way to try to shrink with no fragmentation is to use...

    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: Loading a local temp table taking more than 24 hours

    Several things to consider here. I'll number them so that everyone can comment on them more easily:

    1) Make sure IFI is on (just in case).

    2) Pre-allocate additional space 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".

Viewing 15 posts - 4,111 through 4,125 (of 7,613 total)