Forum Replies Created

Viewing 15 posts - 16 through 30 (of 1,413 total)

  • Reply To: Case part is sloooooow

    Maybe the issue is the query could possibly be more efficiently evaluated if expressed as two queries.  It always depends on the actual situation with cardinalities and indexes etc.  If...

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

  • Reply To: Two foreign keys to the same table. Can't cascade deletes.

    1.  It's not allowed.
    2. SQL Server wants to guarantee a single parent delete cannot reach the same target row by more than one cascade route.  Multiple cascade paths are not...

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

  • Reply To: Simplifying WHERE Condition with LIKE test on multiple columns

    Sure redesign if possible.  As far as the task at hand it depends on the number of rows really.  If there are a good many rows then allocating a temp...

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

  • Reply To: Need to overload tempdb

    Ha yeah I was reluctant to test it out.  Sorry for the syntax issues.  Originally I had a table CREATE statement but then switched to SELECT INTO because that's more...

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

  • Reply To: Need to overload tempdb

    How about creating a giant temp table from a CROSS JOIN using 2 fnTally functions.  Then join the temp table to itself forcing a HASH JOIN with tiny memory grants...

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

  • Reply To: Beginner in sql server

    Assuming this is dev or the table is empty, DROP and recreate with the proper column type and default.  Something like this

    drop table if exists dbo.latest_info;
    go
    create table...

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

  • Reply To: Beginner in sql server

    You're looking to set the DEFAULT value of the publish_date column to be the current Unix timestamp?  If so the proper column type would be BIGINT.  SQL Server’s native datetime...

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

  • Reply To: Varchar(max) to lines

    Summary
    + Input: long varchar text; max line width W.
    + Walk left-to-right, one word at a time.
    + Separators: space; CR/LF are hard line breaks.
    + For each word:
    ...

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

  • Reply To: Is there a way for SP to know who called it?

    If there are alternate code paths which depend on the client then spare a thought for the optimizer. This pattern implies parameter sniffing imo.  To the extent there are separate...

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

  • Reply To: Work out closing balance using opening balance of prior month

    Ah yes, I see that now.  Thanks Jeff.  In my head I did check to make sure the dates within the partition were unique and then told myself "nothing to...

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

  • Reply To: Work out closing balance using opening balance of prior month

    Yes I agree pietlinden has the correct approach imo.  SUM OVER provides a running total without recursion

    select *, sum(OpenOpps+CreatedOpps+WonOpps+LostOpps) over (partition by Division order by [Date]) running_total
    from...

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

  • Reply To: SUM([value]) and highest record type

    DROP TABLE IF EXISTS #data_table;
    GO
    CREATE TABLE #data_table (
    Id INT PRIMARY KEY,
    Model INT,
    RecordType INT,
    ...

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

  • Reply To: Dependency Chain

    It took some testing to get the recursion working.  From the reference paths it's not clear how to proceed tho.  Maybe you're looking for the maximum level for each ProcedureName?

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

  • Reply To: Is there an ISERROR equivalent in SS?

    water490 wrote:

    How do I code "calc1 has error"?  The above code is part of a larger code where results results are passed up from sub-query to parent query so...

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

  • Reply To: New lightweight pure‑T‑SQL unit‑testing framework (T‑TEST) — feedback welcome

    Very nice.  The chess app is interesting too.  Could you explain the project structure of the chess app a little more?  There appears to be more than one chess engine

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

Viewing 15 posts - 16 through 30 (of 1,413 total)