Forum Replies Created

Viewing 15 posts - 1,126 through 1,140 (of 7,619 total)

  • Reply To: Write 2 complex queries

    The patient's name is not present anywhere.  That is, there's no way to know who patient "A", let alone to know what doctor(s) he/she saw.

    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: SQL Query Help on Time based query

    Jeff Moden wrote:

    This is so wrong.  Your company is trying to have you fix the wrong problem.  The real problem is the source of the data and THAT's what actually needs...

    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: SQL Query Help on Time based query

    This was an interesting problem because for 'Shift' rows, you need to output only one row.  But for non-'Shift' rows, you (mostly) need to output two rows: a row 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".

  • Reply To: best way to extract name and number

    I wouldn't go thru all those gyrations to pull out the values.  Imagine the hassle to just add one more column to the output.

    I'd do something similar to this instead.

    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: SQL Query Help on Time based query

    I think this will work.  I have NOT yet adjusted it for performance (or tuned it at all yet, really), I was just trying to make it work.  Let me...

    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: help with SQL query PGADMIN

    As noted, a LEFT JOIN is what you need.  An INNER JOIN requires a matching row in both tables; a LEFT JOIN will keep the row from the left-hand table...

    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 alias or update tablename when from clause is specified

    You must use the alias to insure accurate UPDATEing.  You can, and quite often will, get inaccurate results when using the full table name instead.  (The error may now only...

    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: help with SQL query PGADMIN

    I agree, sounds very much like class work.

    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: Get Summary Data for Last 52 weeks by Week

    Actually you're pulling more than 52 weeks' worth that way, but here goes.  Note that since you provided no sample data to test it with, you'll need to do 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".

  • Reply To: Why is the MS calculation for SQL Server table size not reflect Storage in SSMS

    Excellent idea.  That gets much closer to the given size.

    There's one very minor miscalc above, in that I believe page data can never exceed an absolute max of 8060 bytes,...

    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: How to capture particular text from standard column to populate computed column

     

    SELECT title, 
    SUBSTRING(title, CHARINDEX('E00', title), 200),
    Computed = CASE WHEN CHARINDEX('E00', title) = 0 THEN NULL
    ...

    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: Why is the MS calculation for SQL Server table size not reflect Storage in SSMS

    Would you script out the table to make sure no other column "snuck" in there?

    And please verify the row count:

    SELECT SUM(rows) AS row_count
    FROM sys.partitions
    WHERE object_id = OBJECT_ID('dbo.SIData_222222_88_20211103_1436')...

    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: Truncate vs Delete for Bulk Removal of (some not all ) records

    Then follow the standard method and delete from the table in batches in clus key order.

    In order to do that, you might first have to go thru the table and...

    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: Truncate vs Delete for Bulk Removal of (some not all ) records

    Well, if the datetime in the clus index is current datetime, you're ok.  Otherwise, not good, since you wouldn't be able to easily tell when copying the "good" rows 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".

  • Reply To: Issue with joining 2 temporary tables

    I got an email with just the initial q, I just quickly reviewed all the comments above, but my first thought was this:

    ;WITH ACTUALS 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".

Viewing 15 posts - 1,126 through 1,140 (of 7,619 total)