Forum Replies Created

Viewing 15 posts - 3,031 through 3,045 (of 7,619 total)

  • RE: Error: Cannot insert duplicate key row in... a non-unique index?!

    Eric M Russell - Tuesday, December 18, 2018 3:20 PM

    Jeffrey Williams 3188 - Tuesday, December 18, 2018...

    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: Validate date stored as a string as a complete, valid date

    If you're on SQL 2016 (or even SQL 2012), just use TRY_CAST:


    SELECT s
    ,TRY_CAST(s AS date) AS MyDate
    FROM @t

    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: Error: Cannot insert duplicate key row in... a non-unique index?!

    Eric M Russell - Monday, December 17, 2018 12:50 PM

    I'm not on the ETL team, so I can't vouch for the specifics...

    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: Help Using CASE instead of IF/. ELSE

    Phil Parkin - Monday, December 17, 2018 12:36 PM

    It may be worth considering putting a computed LocationCode column on your table. This...

    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: Error: Cannot insert duplicate key row in... a non-unique index?!

    Eric M Russell - Monday, December 17, 2018 12:25 PM

    ScottPletcher - Monday, December 17, 2018 12:11 PM

    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: Help Using CASE instead of IF/. ELSE

    Assuming location is "01", "02", etc., when passed in, then:


    Select *
    from table_1
    Where
    ID = @ID
    AND Printing = 0
    AND Salary =...

    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: Error: Cannot insert duplicate key row in... a non-unique index?!

    None of those indexes match the name in the error message.

    What is the DDL for index 

    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: Subquery - another way to achieve the same result?


    select v1.amount,
        sum(case when v1.ConfirmedAt is null then 1 else 0 end) as ConfirmNullCount,
        sum(case when datediff(day,v1.confirmedat,getdate())<365 then 1 else 0 end)...

    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: COALESCE Issues when controlling logic in a tvf

    Extremely vague.  But in general, rather than actually SELECTing the data, using EXISTS() to check for it is more efficient.

    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 can I combine the three queries to one and possibly improve performance

    If you wanted to always keep the original temp table, that's fine.  I don't have a problem at all with that.

    But write the q that way then

    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: Interesting Use Case Of CEILING

    Float values are not exact, they are approximate.  Internally, float 0.55 might be 0.550000000001.  CEILING goes up to the next int value no matter how small the amount above the previous...

    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 can I combine the three queries to one and possibly improve performance

    I'm genuinely confused.

    Your q states"How can I combine the three queries to one".  We write queries that combine the 3 queries into a single query. 

    But then...

    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: Where did our 30GBs go?

    scarr030 - Tuesday, December 11, 2018 10:49 AM

    ScottPletcher - Tuesday, December 11, 2018 10:27 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 can I combine the three queries to one and possibly improve performance

    It could be more efficient to get only typeid from table1 in the first pass, like below.  This depends on indexing and the cardinality (how many t1 rows have typeids...

    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: Where did our 30GBs go?

    scarr030 - Tuesday, December 11, 2018 6:08 AM

    Jonathan AC Roberts - Monday, December 10, 2018 7:22 PM

    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,031 through 3,045 (of 7,619 total)