Forum Replies Created

Viewing 15 posts - 3,331 through 3,345 (of 7,619 total)

  • RE: Return last amount larger than 0

    I'd check column separately rather than adding them, just in case negative amounts could appear now, or somehow do appear later:

    WHERE CE.CLOSING_CREDITS <> 0 AND CE.CLOSING_DEBITS <> 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".

  • RE: Friday Fun - Excel Formula to SQL Functions

    Also, you want to avoid BETWEEN when dealing with dates / times.
    I have heard this often but I have never seen any proof as to why. I 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: Top 2 records with range


    SELECT TOP (2) IDUser, Score, Name
    FROM (
      SELECT U.IDUser, U.Score, U.RecordDt, S2.Name,
          ROW_NUMBER() OVER(PARTITION BY U.IDUser, S2.Name ORDER BY U.RecordDt DESC) 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: Friday Fun - Excel Formula to SQL Functions

    I think something like below is much easier to follow.  Also, you want to avoid BETWEEN when dealing with dates / times.

    I can't tell for sure if 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".

  • RE: Join on a substring value

    Or, better yet, just go back to properly using 1NF in the table and store all values as atomic, i.e., individual columns.  The computed column should be the concatenated value,...

    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: carving out bussiness hours.

    DesNorton - Tuesday, June 12, 2018 12:07 PM

    This should give you the the AVG per day as well as the AVG for...

    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: A few quick questions about sysjobhistory table

    1) No, afaik.
    2) Yes, [H]HHHMMSS.
    3) I've no longer got CDC jobs really, but I don't remember seeing that phenomenon when I did, very interesting.

    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: Join on a substring value

    WHERE/ON SUBSTRING(string, CHARINDEX('-', string) + 1, 5) = ...

    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: carving out bussiness hours.

    To get the avg total time, you could do this:

    DATEADD(SECOND, SUM(DATEDIFF(SECOND, 0, TotalTime)) / COUNT(TotalTime), 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".

  • RE: Multiple sub queries used to derive the columns for the select list.

    Here's a rewrite of the first query (before the UNION ALL).  I don't have time to do both but they look very similar.  The second two subqueries can be combined...

    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 enrich, multiple columns on a table from another DB

    Create a new table on database A to hold database B's data: host name, OS info, etc.  For the sake of argument, let's say the new table is named "ip_details". ...

    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: Affinity Mask...

    e4d4 - Sunday, June 10, 2018 1:16 PM

    ScottPletcher - Friday, June 8, 2018 2:23 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: Affinity Mask...

    Are you licensed for all the CPUs?  At one time, the affinity mask was used to run on machine that had more processors than you were licensed for, by cancelling...

    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 spread an invoice tax across invoice lines without loosing rounded remainder in a view?

    Not easily, no.  With the current query,for example, we have no way of knowing which row is the last pax.

    Btw, you should truncate not round, or you will...

    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: carving out bussiness hours.

    This is relatively straightforward (the difference between start time and end time, for selected hours only), but you'll need to post directly usable data.  That is, CREATE TABLE and INSERT...

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