Forum Replies Created

Viewing 15 posts - 2,416 through 2,430 (of 7,613 total)

  • Reply To: Clustered Columnstore Indexing Tips and ETL Load Performance

    1 The nonclus indexes should be unique, not non-unique.  Worst case, add an identity to the table and use that to make unique non-clus keys.

    2 Are the nonclus indexes page...

    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: Nested Views and General ETL Design Advie

    Create two base source tables: one with only current_record = 'Y' rows, and one with only current_record <> 'Y' rows.  Create a SQL constraint on the each table that enforces...

    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: Query Performance

    1.2M rows * 10KB bytes per row is a huge amount of data, ~12GB.  I can imagine it could take 6 mins to transfer that much data.

    It would be very...

    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: Trouble with Finding Dependencies between Tables using Keys

    As I noted above, views sys.foreign_keys and sys.foreign_key_columns should give you FK details.  I can't imagine how your SQL doesn't have those views, since they've been around a long time.

    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: Trouble with Finding Dependencies between Tables using Keys

    Agreed.

    Views sys.foreign_keys and sys.foreign_key_columns should give you FK details.

    Also look at sys.dm_sql_referenced_entities and sys.dm_sql_referencing_entities.

    For just any reference to another object, not for a defined relationship, try sys.sql_expression_dependencies.  For example, if...

    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: Finding a range of date within a range of date

    I prefer this method:

    declare
    @start_dt datetime='2019-12-02',
    @end_dt ...

    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: Search with Full Text Index vs "normal" search

    You need to be aware that "Execution plan Query cost relative to the batch" is meaningless.  SQL is very often quite wrong on this number.  Just ignore it!

    You need 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".

  • Reply To: Adding another table to a query but only wanting the top 1 for each record

    Great.  I guess that confirms it gave you the results you 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".

  • Reply To: Adding another table to a query but only wanting the top 1 for each record

    LEFT OUTER JOIN (

    SELECT *, ROW_NUMBER() OVER(PARTITION BY customer, ApplicationName ORDER BY Created DESC) AS row_num FROM [CIS].[dbo].[patches]

    ) AS patches ON patches.customer = a.number and patches.ApplicationName = custapps.app AND patches.row_num...

    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: Adding another table to a query but only wanting the top 1 for each record

     

    SELECT ...same_as_before_except_add_patches_columns...
    FROM customers

    LEFT OUTER JOIN (
    SELECT *, ROW_NUMBER() OVER(PARTITION BY customer ORDER BY Created DESC) AS row_num
    FROM [CIS].[dbo].[patches]
    ) 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: Importing csv file into SQL table

    What I usually do in those situations, if the file's not way too extremely large (2GB max file size; for any size up to 1.5GB, I've found that it takes...

    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: Room booking system - calculating room occupancy

    I think this will give you what you need.  I went down to the minute to allow bookings like '10:10' to '10:45'.  You may not have that now, but it...

    • This reply was modified 6 years, 3 months ago by ScottPletcher. Reason: Added comment about tally table size
    • This reply was modified 6 years, 3 months ago by ScottPletcher. Reason: Changed the tally table to be 10K rows instead of 1000

    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: I was asked to get rid of this Dynamic SQL for performance purposes.

    You're right, you can't avoid dynamic SQL here.  You need dynamic SQL here to insure you get the best query 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: Get the correct output

    Steve Collins wrote:

    Steve and Jeff, thank you.  Good to have other eyes on this. 🙂  What should I do with the earlier incorrect code?  Wipe it out?  Should I have kept...

    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: Get the correct output

    I'd stick with something more SQL-ish, and also more readily readable and understandable, like below.  If you're converting Access to SQL Server, it's convenient to use IIF, otherwise avoid 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".

Viewing 15 posts - 2,416 through 2,430 (of 7,613 total)