Forum Replies Created

Viewing 15 posts - 1,171 through 1,185 (of 7,613 total)

  • Reply To: SQL query help

    If I understand correctly, you just need to add the condition on the JOIN:

    ...previous_part_of_query_same_as_before...

    INNER JOIN #temp_Lookback t2 ON t1.Id = t2.PreviouslyCompletedId AND t2.Type = 'F'

    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: Best Practice question

    You'd typically want to use dynamic SQL for this, so that only the relevant columns were included in the comparisons.  You'll also typically want to recompile to get a specific...

    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: Performance question View vs SQL query within view

    It definitely could, esp. if there's an index containing the type column.

    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: Performance question View vs SQL query within view

    First try refreshing the view.  The "*" in the view may be causing some issues if the table has changed after the view was created.

    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: Best practice to store - How many days, minute and second ?

    Jeff Moden wrote:

    ScottPletcher wrote:

    I'd say it depends on how often you need to show the resolution duration.  That's a rather complex calc to do repeatedly..

    I have to disagree.  If you 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".

  • Reply To: Best practice to store - How many days, minute and second ?

    I'd say it depends on how often you need to show the resolution duration.  That's a rather complex calc to do repeatedly.   And presumably the Resolution Time would only be...

    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: Update table FirstName & LastName from Email addresses

    Sorry.

    SET ANSI_NULLS ON
    SET QUOTED_IDENTIFIER ON
    GO
    CREATE FUNCTION [dbo].[DelimitedSplit8K] (
    @pString varchar(8000),
    @pDelimiter char(1)
    )
    RETURNS TABLE WITH SCHEMABINDING
    AS
    /*SELECT *...

    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: Unable to execute Auto_Increment

    A few other things need changed to match SQL Server syntax as well.

    CREATE TABLE "circuits" (
    "circuitId" int NOT NULL IDENTITY(1, 1), --<<--
    "circuitRef" varchar(255)...

    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: Update table FirstName & LastName from Email addresses

    Let's fall back on the old reliable dbo.DelimitedSplit8K function, to avoid doing all the parsing ourselves.

    ;WITH sample_data AS (
    SELECT * FROM ( VALUES
    ...

    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: Update table FirstName & LastName from Email addresses

    UPDATE ...

    SET FirstName = PARSENAME(LEFT(EmailAddress, CHARINDEX('@', EmailAddress) - 1), 1),
    LastName = PARSENAME(LEFT(EmailAddress, CHARINDEX('@', EmailAddress) - 1), 2)

    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: Setting Up SQL Server 2019 for Optimal Performance

    Yes to the most RAM you can get and actually use for SQL Server: 128GB for Standard Edition, as much as you can afford for Enterprise.

    Note that, if Standard Ed,...

    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: Printing Strings Longer Than 8000 Characters

    You can write them to a table -- add an identity for ordering -- and then SELECT from that table, for example:

    SELECT sql_text AS [--sql_to_run]

    FROM #some_table_name

    ORDER BY $IDENTITY

    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 help

    You didn't say what the result should be if it is tied, for example, 2F and 2M?  In that case, I went with 'FemaleMix', adjust that if 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: Printing Strings Longer Than 8000 Characters

    You need to change the Options..., Query Results, SQL Server in your SSMS to display more chars.

    You don't need (nor likely want) to toggle to text.  A grid display should...

    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: Printing Strings Longer Than 8000 Characters

    My first suggestion would be to use SELECT rather than PRINT, since SELECT goes up to 65535 chars (I believe, if you have the options set that way in SSMS).

     

    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,171 through 1,185 (of 7,613 total)