Forum Replies Created

Viewing 15 posts - 3,631 through 3,645 (of 7,613 total)

  • RE: Trigger to avoid drop online database

    I don't know about detach at this point, but with some "fancy footwork" you can DROP a database only if it was OFFLINE.  You have to rollback the DROP, of...

    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 convert kilograms to pounds and ounces

    John Mitchell-245523 - Friday, December 29, 2017 8:23 AM

    ScottPletcher - Friday, December 29, 2017 8:18 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: How to convert kilograms to pounds and ounces

    Or perhaps multiply by 2.2046226218, or some shorter variant of that, if you need more accuracy.  2.2 is rather rough estimate.

    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 hardcoded database names in query when database names are different on development and production server

    Maybe easy, maybe not.  You have to create a synonym for every remote object you reference.  And keep them in sync if, for any reason, you have to rename an object.

    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 hardcoded database names in query when database names are different on development and production server

    That's going to be a royal pita.

    Why not just stop using different names for dev and prod?  It's easier to mess up the aliasing than it is 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".

  • RE: INDEX range_scan_count

    From Books Online, under sys.dm_db_index_operational_stats:

    sys.dm_db_index_operational_stats (Transact-SQL)range_scan_count  bigint  Cumulative count of range and table scans started on the index or heap.

    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: Table updates on large table with no ID or large gaps between IDs

    Go by the values in the clustered index.  For example, if the table is clustered on a datetime column, use that as the value for the UPDATE.

    Here's 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: Can someone explain how this works

    macbaze72 - Thursday, December 21, 2017 4:04 PM

    This code works, but I don;t understand it.  The part I need some clarification 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".

  • RE: Suggestions on a query plan

    The key lookups should cost more than the sort for only 7 rows (I know the lookup is in both queries).  You should consider adding DateRegistered to the NC lindex.

    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: Logic to check for empty table before joining

    Be sure to create a unique clustered key / primary clustered key on SiteKey in the #Sites tables.  With only ~20+ rows it may not matter, but it can't hurt.

    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: sql to bypass "dayofweek" and "days" functions

    DayOfWeek 7 is ambiguous in SQL Server, since SQL allows the week to start on any day that you specify.

    Instead, I'd strongly urge you to use known day...

    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: Rebuilding a table

    If you can, TRUNCATE the table rather than DELETE all the rows, as trunc will be much less overhead (btw, in case you're wondering, a trunc can be rolled back...

    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: Coffee sales for just 7am to 8am but for the entire year?

    Sorry about the HOUR(), that's the one function I always forget doesn't exist.  Per quarter for the current year, something like this:


    select
      DATEPART(quarter,...

    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: Coffee sales for just 7am to 8am but for the entire year?

    Not 100% sure what you need, but, for example, this gives sales for the latest quarter for >=7AM and <8AM:


    select *
    from TicketItem
    where s_item...

    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: Difference between dates displayed in days, hours, minutes and seconds

    Below is alternative method that's closer to the original technique (for good or ill).  Btw, there's a minor bug in the other code that doesn't reduce the day count 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".

Viewing 15 posts - 3,631 through 3,645 (of 7,613 total)