Forum Replies Created

Viewing 15 posts - 556 through 570 (of 1,414 total)

  • Reply To: Calculate count of credit decision (One or multiple custom sql)

    Imo you could maybe start with a query like this.  The 'final_cte' CTE selects the row(s) with the final status for each Deal.  Then OUTER APPLY is used to count...

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

  • Reply To: Calculate count of credit decision (One or multiple custom sql)

    It's not a good logical model.  What is the maximum number of rows per Deal?  If it's 2 you could join the table to itself

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

  • Reply To: Dynamic SQL? Inserting Sproc data into table variable

    I just ran into this same issue.  The short answer is to create a #temp table instead and it works (because the temp table exists within the same execution context...

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

  • Reply To: Are the posted questions getting worse?

    Lynn Pettis wrote:

    I was off topic??

    The other comment.  Your comment was very on topic 🙂

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

  • Reply To: Are the posted questions getting worse?

    Lynn Pettis wrote:

    Wow, what a way to respond to an obvious joke.

    Off topic much?  A couple is 2 and a few is 3 and more than a few is 5 but...

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

  • Reply To: Asking for suggestions for our SQL database/table architecture

    Well a lot could said about this topic.  The classic threaded forum/subforum organization might seem straightforward it depends on many things.  If by "threaded" it means "nested html" then that's...

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

  • Reply To: update final code where not contain x then null if not contain x and another cod

    Maybe you could use a CTE to make sure the right table source of the JOIN in the UPDATE statement contains appropriate unique priorityCode's

    with unq_priority_cte(priorityid,priorityCode,priorityname) as (
    ...

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

  • Reply To: How to return a range value based on the first day of year and the value of row

    Ken McKelvey wrote:

    Steve Collins wrote:

    this looks familiar

    I think both windowed and brute force approaches have their place. I have just tidied up my code to try and make it more understandable:

    It...

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

  • Reply To: How to return a range value based on the first day of year and the value of row

    Ken McKelvey this looks familiar

    https://www.sqlservercentral.com/forums/topic/need-to-create-gaps-in-a-table-of-date-ranges

    Again one "brute force" way to do this would be to expand all the date ranges and use the set operator EXCEPT to remove the (also...

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

  • Reply To: How to return a range value based on the first day of year and the value of row

    It's a one time only type query or it's intended to be run frequently?  The id value in the last row of the sample data should be 5, no?

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

  • Reply To: Most recent and previous row

    O sorry, I was thinking you meant 2nd from the end.  I seemed to have missed the date range part too

    declare @StartDate DATE = '2021-09-24', @EndDate DATE...

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

  • Reply To: Most recent and previous row

    You could try using ROW_NUMBER twice.  Once to find the most recent row within the MyIdentifier partition and then again to find the 2nd oldest row (also within the MyIdentifier...

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

  • Reply To: GUIDs as clustered index

    Jeff Moden wrote:

    Call it what you want, using a GUID to "represent the PK" or vice versa makes no sense to me.   Both columns are fixed width (unless you've done row...

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

  • Reply To: GUIDs as clustered index

    Maybe it was incorrect to label the GUID column 'guid_id' because it was intended as a public attribute of the primary key. Maybe it would be better labelled as 'securitystamp'...

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

  • Viewing 15 posts - 556 through 570 (of 1,414 total)