Forum Replies Created

Viewing 15 posts - 2,611 through 2,625 (of 7,613 total)

  • Reply To: Using subquery count to subtract from main query count

    SELECT count(c.people_id) AS 'Inactives' --<<-- note counting from *right* table
    FROM [BCC_DB].[dbo].[People] p
    LEFT OUTER JOIN --<<-- note *LEFT* join
    [BCC_DB].[dbo].[certs] c
    ON p.peopleId = c.peopleId
    WHERE p.status = 1
    AND...

    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: Distance Zip Code Database

    Presumably you want the driving distance and not the "as the crow files" (straight linear) distance.  For that you will need a software package.  You will also need to get...

    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: Running Totals by Date and Account

    ...

    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: Running Totals by Date and Account

    ...

    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 help with a Query

    The codes look ok.  Something else must be causing your issue.

    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: Replace TABLE with STAGING_TABLE. Approach?

    You can use a query to see which table the view is currently pointing at:

    SELECT referenced_schema_name, referenced_entity_name

    FROM sys.sql_expression_dependencies

    WHERE referencing_id = OBJECT_ID('dbo.Clients')

    Also, I'd suggest creating a log table in which 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".

  • Reply To: Clustered Columnstore Index and Partition Elimination

    I don't think so, I think 0 should mean your query accessed no partitions.  If it had accessed all of them, the total number of partitions should be there.

    Review 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".

  • Reply To: One table or two?

    I would never combine these tables.

    I'd be much more concerned with determining the best clustered keys for each table.  Or whether, perhaps, they would best be heaps (individual rows are...

    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: repeating block of records

    Can you post directly usable data, i.e., CREATE TABLE and INSERT statements.

    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: does WITH (NOLOCK) hint in Select statement really make a difference?

    Chris Harshman wrote:

    ScottPletcher wrote:

    Chris Harshman wrote:

    NOLOCK probably does not do what you think it does.  It still will take out locks for itself on the tables you are querying

    I don't think 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: does WITH (NOLOCK) hint in Select statement really make a difference?

    Chris Harshman wrote:

    NOLOCK probably does not do what you think it does.  It still will take out locks for itself on the tables you are querying

    I don't think so.  Where did...

    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: Multi-column pivot table help

    CREATE TABLE #table_1 (
    last_updated date NOT NULL,
    type_desc varchar(30) NULL,
    size_bytes bigint NULL,
    used_bytes...

    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: does WITH (NOLOCK) hint in Select statement really make a difference?

    Chris Harshman wrote:

    Other than some advanced troubleshooting cases like Jonathan says, there is no reason you should use NOLOCK in your code.

    NOLOCK probably does not do what you think it does. ...

    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 am looking to optimize this T-SQL Statement (it generates very High Reads..)

    All indexes are tuned to their best (for the current statement)

    I'd rather see the actual indexes and the actual query plan for myself.

    For example, how many rows are in #GRatings...

    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: result in same line

    No usable sample data, so I can't test it, but this should give you the results you want:

    SELECT $month_of_year, $day_of_month,

    SUM(CASE WHEN status ='success' THEN 1 ELSE 0...

    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,611 through 2,625 (of 7,613 total)