Forum Replies Created

Viewing 15 posts - 3,421 through 3,435 (of 7,613 total)

  • RE: Updating Rows

    This should be enough to UPDATE the udf table:


    UPDATE udf
    SET Value = CASE udf.fieldno WHEN 1 THEN udf1 WHEN 2 THEN udf2 WHEN 3...

    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: Most efficient way of not selecting data

    As noted, use NOT EXISTS.  Also, uniquely cluster the NoEmail table on the EmailAddress.


    ...
    CREATE TABLE #tblNoEmail
    (
    EmailAddress varchar(100) PRIMARY KEY CLUSTERED
    )
    ...
    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".

  • RE: UDF showing weird behavior when checking if variable holds null value.

    2) The question should be. When needing the result from one query multiple times in a procedure/UDF/trigger, is it best to store it in a variable or run that...

    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: UDF showing weird behavior when checking if variable holds null value.

    Local variables tend to slow down scalar functions, so avoid them if possible.  In this case, they also make the logic much more complicated than it needs 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: Number of Days between two Day Names

    Don't have a lot of time, but this should be real close at least:

    SELECT *,
      CASE WHEN EndDayNumber >= StartDayNumber THEN EndDayNumber - StartDayNumber
       ELSE...

    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: Backups of read-only databases

    and will make it harder in the recovering process.

    I don't understand why you'd say that.  The main reason I could see for continuing to do backups 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: Group by month and year

    Jeff Moden - Monday, April 30, 2018 11:43 AM

    jcelko212 32090 - Monday, April 30, 2018 10:46 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: Group by month and year

    jcelko212 32090 - Monday, April 30, 2018 10:46 AM

    You don't seem to understand that dates are not kept in strings in SQL....

    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: Change Data format

    As noted, the datetime is stored in a numeric format.

    It's likely that whatever interface is displaying the date to you is putting it in this format:
    Apr 19...

    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: Extract phone numbers from a string


    SELECT *,
        CASE WHEN string2 LIKE '%[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%'
             THEN SUBSTRING(string2, PATINDEX('%[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]%', string2), 10)
             ELSE NULL END 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: Group by month and year

    Don't use functions on any column unless you have absolutely no choice. In other words, keep the condition sargable if at all possible


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

  • RE: Check constraint where all records with the same effective date add up to one

    You could make the restriction 100% or less.  The main thing is not overfill it, right?  That would allow changes, you would just have to remove/reduce something before adding something...

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

    sgmunson - Wednesday, April 25, 2018 1:59 PM

    ScottPletcher - Wednesday, April 25, 2018 9:49 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: Combine rows returned from within a Cursor loop into one Result


    SELECT *
    FROM PeopleDetail PD
    WHERE PD.Name IN (
        SELECT Name
        FROM People
    )

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

    sgmunson - Wednesday, April 25, 2018 8:03 AM

    ScottPletcher - Tuesday, April 24, 2018 2:57 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,421 through 3,435 (of 7,613 total)