Forum Replies Created

Viewing 15 posts - 1,216 through 1,230 (of 1,424 total)

  • Reply To: Storing results in tables with dynamic names

    Maybe successively cross apply with partial joins?  Something like:

    with
    matrix_1(month_nbr, x_group, [1], [2], [3]) as (
    select 1, 'grp a', 1, 1, 1
    ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Help with SQL query

    Yes, union all works well.  Or you could insert into @Temptable twice.  It's not clear whether the information in the inserted 'Invoice' should contain all of "same informations (ID,DKey,SKey)..." because...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: is WITH (ROWLOCK) hint a culprit in this code?

    The whole retry loop could be removed in my opinion.  This is a basic upsert.  The variables used for flow of control are deterministic so the retry is not really...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Relatively easy query assistance - datediff

    with
    hotel_cte(customer_id, type_of_event, event_dt) as (
    select 1, 'check in', '2019-12-30'
    union all
    select 1, 'check out', '2020-01-14'
    union all
    select 2, 'check in', '2020-01-14'
    union all
    select 2, 'check out', '2020-01-22'
    union all
    select 3, 'check...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How to make group by Revision_ID and when repeated display last check date separ

    Final answer, shamelessly borrowing from Jonathan, still without CROSS APPLY.  Also, Jonathan's answer with sample data cte included (copy/paste/run).

    /* borrowed */
    with
    LifeCycleMaster_cte(Revision_ID, ZPartID, LastCheckDate) as (
    select 12, 10,...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How to make group by Revision_ID and when repeated display last check date separ

    Well I was close.  Should've summarized from the beginning.  I thought about CROSS APPLY but it seems fussy when there's no TVF because there's still the old ways.  The DISTINCT...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: How to make group by Revision_ID and when repeated display last check date separ

    with
    LifeCycleMaster_cte(Revision_ID, ZPartID, LastCheckDate) as (
    select 12, 10, '12/12/2015'
    union all
    select 15, 120, '12/01/2014'
    union all
    select 15, 130, '05/05/2016'
    union all
    select 20, 170, '09/03/2013'
    union all
    select 20, 200, '09/05/2016'
    union all
    select 20, 300,...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Need help with SELECT statement

    One way to simplify things could be to resolve the hierarchical adjacency between airports, countries, and areas using a table.  The ServicLevel case logic could also be replaced by a...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: how to find gaps between range

    rajemessage 14195 wrote:

    1) two tables store range data related to two different activities, but for simplicity, I have removed other cols.

    Currently there's no way to join rows from table t...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Updating a column value without intermediate column

    How is the data model originally populated?  The examples provided set IDENTITY_INSERT ON.  Are the examples representative of how inserts into the Child db tables occur in actual usage cases? ...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: how to find gaps between range

    How does table t join to table t1?  Are the rows intended to be in sequential 1-to-1 correspondence?  If yes, why not create only 1 table instead of 2?

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Import JSON file through ADF (from blob to SQL DW)

    Is it required to read the file using ADF?  There are a few ways to do it with just Sql Server (and without ADF).   The Json could be read from...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: func_GetInvoiceNumberByDocumentNumber

    Here's my attempt.  Because you're expecting a lot of rows from this query I wouldn't bother with outer applying top(1)'s.  Rather it might make sense to break the cte into...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Looking for a very heavy query against AdventureWorks DW database for DEMO

    Have you considered using a tool to simulate requests?  Some DBA's are cynical about performance claims.  Sometimes vendor examples are designed to support the solution being offered by salesmen.  I've...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

  • Reply To: Looking for a very heavy query against AdventureWorks DW database for DEMO

    You could row multiply and summarize across large sequences using a tally function and it wouldn't matter which db instance.  These peg the cpu at 100%.  If you'd like it...

    Aus dem Paradies, das Cantor uns geschaffen, soll uns niemand vertreiben können

Viewing 15 posts - 1,216 through 1,230 (of 1,424 total)