Forum Replies Created

Viewing 15 posts - 3,541 through 3,555 (of 7,613 total)

  • RE: Triggers or best option

    Short answer:
    You want a dynamically-generated, static trigger.  That sounds contradictory but it's not.

    More detailed answer:
    You must meet two critical conditions here:
    1) the trigger must execute as...

    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: Optimize sub queries into single query.


    Select Count(*) as XmlEventsCount,
        Max(case when x.Status = 'NOTE' THEN 'Yes' ELSE 'No' END) as SentToProvider
    From TicketEvents x
    Where x.RowID=1136394
    Group By x.RowID

    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: finding the right index

    Jackie Lowery - Monday, February 19, 2018 4:14 PM

    ScottPletcher - Monday, February 19, 2018 2:45 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: finding the right index

    Nope, it actually doesn't.  By default SQL will make it so, but it doesn't have to 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".

  • RE: finding the right index

    Wow, yeah, for sure cluster by DateSent if that's the case.  The other conditions won't matter.

    Btw, the other tables I was worried about being scanned, I had more...

    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: finding the right index

    Yep, that's fine.  The results are interesting.

    1) Do you often/very often search by a SentDate range?
    2) Is a 1 year range typical for a date search? ...

    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: finding the right index

    First thing is to make sure you have the best clustering index on the table.  Then we'll look to see if additional indexes or code changes or other things 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".

  • RE: Help me with the SELECT statement please ?

    Jeff Moden - Wednesday, February 14, 2018 6:31 AM

    The biggest problem with this whole thing is the notion of storing the year...

    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: Querying against a multi-ID/Value table

    thinkink07 - Monday, February 12, 2018 1:27 PM

    drew.allen - Monday, February 12, 2018 12:24 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: Use a case statement within a function parameter.

    You could try using a CROSS APPLY to assign the alias name, then use that alias in the SELECT clause:

    SELECT ...,
        ca1.STAGE_022_COMPLETED_DATE_IS_NULL_REV_DATE,
        [dbo].[fnc_CalcWorkDaysBetween] (ca1.STAGE_022_COMPLETED_DATE_IS_NULL_REV_DATE,...

    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: Split 60 character string every third character with pipes

    Float doesn't have nearly 60 digits of precision, does it?

    SELECT REPLACE(CAST(FORMAT(CAST('123456789012345678901234567890123456789012345678901234567890' AS float),
    '### | ### | ### | ### | ### | ### | ### | ###...

    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: EXISTS/ ALL?

    Basically this:

    SELECT SCandidateID
    FROM dbo.CandidateSkills
    WHERE Skill IN (@ssrs_skill_param)
    GROUP BY SCandidateID
    HAVING COUNT(*) = <number_of_values_in_skill_param>

    But not sure how in SSRS to get a count 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: Split 60 character string every third character with pipes

    DataAnalyst011 - Thursday, February 8, 2018 11:31 AM

    ScottPletcher - Thursday, February 8, 2018 10:39 AM

    I...

    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: Split 60 character string every third character with pipes

    I say keep it simple unless you really need to do something more complex:

    SELECT STUFF(
        CASE WHEN SUBSTRING(column1, 1, 3) = '000'...

    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 query with this date format ?

    WHERE column_name LIKE '1[67]-Nov-2017%' /* or '%1[67]-Nov-2017%' if the column doesn't start with the 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".

Viewing 15 posts - 3,541 through 3,555 (of 7,613 total)