Forum Replies Created

Viewing 15 posts - 1,786 through 1,800 (of 7,619 total)

  • Reply To: Statistics Update Frequency

    "Tell" SQL to always use a full table scan for those indexes that need it.  Do that by running this one time at your convenience:

    -- index_name is optional, of course

    UPDATE...

    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: How to stop a user creating a new table

    If necessary, you could even add a DDL trigger as a failsafe to make absolutely sure that user doesn't create (or drop) any tables in that db.

    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: How to stop a user creating a new table

    Grant the user the db_datareader and db_datawriter roles, etc., using the commands below.  You can ignore any errors except those dealing with the user's name:

    ALTER ROLE db_datareader ADD MEMBER [your_user_name_here];

    ALTER...

    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: A couple of questions on backward compatibility in SQL Server

    1. No.  You simply cannot restore a backup created in a later version of SQL to an earlier version.  You'd have to use some other method of moving the db...

    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: Help filtering my WHERE clause

    The Dixie Flatline wrote:

    Summing case statements instead of doing a PIVOT, is referred to as a cross tab.

    https://www.sqlservercentral.com/articles/cross-tabs-and-pivots-part-1-%e2%80%93-converting-rows-to-columns-1

    Exactly.  I used a CASE in a SUM but not instead of a PIVOT, so...

    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: Need to SELECT Columns in Table A where one column closely matches in Table B

    You're likely wasting resources by using a CROSS JOIN.  Just do a standard INNER JOIN using the LIKE comparison as the join condition.

    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: String Manipulation Work?

    I can't tell specifically what you want.  Here's by best guess without further details from you:

    ;WITH cte_state_max_sales AS (
    SELECT StateCode, MAX(Sales) AS 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".

  • Reply To: T-SQL SubQuery Help Please

    SQL Server does not automatically determine a row sequence, so you'll need a column in Table B that provides an order, such as an date_inserted or a $IDENTITY column.  For...

    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: Sequences

    If there's still interest for this, I'd be happy to write an article about Sequences, with: set up; uses, including shared uses across many tables; possible issues; etc..

    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: Help with non-clustered index fragmentation

    You may not be rebuilding that specific index.

    The easiest way to rebuild all indexes on a table is:

    ALTER INDEX ALL ON dbo.POHeader REBUILD

    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: Sql query - Projected Monthly Revenue

    The linked article states that "If a date is neither a holiday, nor a weekend day, it is a workday."  But that's not true.  Businesses may be shut because 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".

  • Reply To: Sql query - Projected Monthly Revenue

    The Dixie Flatline wrote:

    It's easy and flexible to include weekends in a Calendar table, usually with two flags one that says weekends, one that says holidays.  Sometimes Christmas falls on a Saturday,...

    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: Help filtering my WHERE clause

    Hmm, I don't believe I used a CROSS TAB.  Yes, I used a CASE in a SUM, but not in a CROSS TAB fashion, from my understanding of a CROSS...

    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: Sql query - Projected Monthly Revenue

    Sergiy wrote:

    gjoelson 29755 wrote:

    Good Point Sergiy.

    Public holidays are also excluded.   , but right now Id just like to solve the weekends and then see if there is a solution for hoildays...

    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: Sql query - Projected Monthly Revenue

    You're welcome!  Yeah, I'm sorry too, but I couldn't figure out exactly what values to return in what columns based on your original query, so I was kinda' forced 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".

Viewing 15 posts - 1,786 through 1,800 (of 7,619 total)