Forum Replies Created

Viewing 15 posts - 541 through 555 (of 1,419 total)

  • Reply To: Replace Numbers

    Wow all that.  Ok maybe something like this

    select IcC.NumericValue,
    stuff((select ''+v.repl
    ...

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

  • Reply To: Replace Numbers

    You feel misled?  It's an axiomatic statement of equivalency

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

  • Reply To: Replace Numbers

    ScottPletcher wrote:

    Your code also has zeros just disappear completely from your results.  It's never explicitly stated that zeros can't appear in these numbers.  Just in case they do, I think...

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

  • Reply To: Replace Numbers

    ScottPletcher wrote:

    Is that code fundamentally different than the first query I posted using the same method?

    No temp table

    No Cartesian product without row goal, i.e. SELECT TOP(n)

    No LEFT JOIN

    No ISNULL

     

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

  • Reply To: How to redesign a query

    Sorry it's not clear to me.  Maybe a more detailed example could help

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

  • Reply To: How to redesign a query

    What are the expected Usage and Result values for each row of the @t table?

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

  • Reply To: Replace Numbers

    Steve Collins wrote:

    maybe something like this

    select ic.NumericValue, 
    stuff((select '' + v.repl
    ...

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

  • Reply To: Replace Numbers

    The REPLACE method maybe is not appropriate here but I still would like to know how that works.  Anyway, given this is version 2016 maybe something like this

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

  • Reply To: Replace Numbers

    Hold a sec, the code above is making multiple replacements of the same character.  7 replaces 1 then 5 replaces 7.  The reason seems to be because the order of...

    • This reply was modified 4 years, 10 months ago by Steve Collins.

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

  • Reply To: Replace Numbers

    This is one of those gray areas... or idk maybe someone can explain why this actually works.  For reasons unknown, afaik when the REPLACE function is used in the righthand...

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

  • Reply To: TSQL: Create dynamic partition DataRange

    Yes a calendar table is another workable approach.  What if the minDate and/or maxDate is other than the 1st or last day of the month?  Maybe something like this

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

  • Reply To: TSQL: Create dynamic partition DataRange

    Yes sorry.  It should've been included.  The code is from Jeff Moden's article here on SSC. It comes in handy in many places

    CREATE FUNCTION [dbo].[fnTally]
    /**********************************************************************************************************************
    ...

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

  • Reply To: How to make row number start by 1 instead of 0 when make union all?

    For the counting to begin at 1 maybe you could assign the value 1 to rows where the status is null.  Then UNION ALL for the additional rows with the...

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

  • Reply To: TSQL: Create dynamic partition DataRange

    There are different date calculations depending on granularity.  This seems to work

    drop table if exists #foo;
    go
    create table #foo(
    [Table] sysname,
    ...

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

  • Reply To: Grouping , time difference in minutes

    Hi Joel, maybe something like this.  It's pretty self-explanatory once you run it

    drop table if exists #foo;
    go
    create table #foo(
    [datetime] datetime,
    tonsperhour...

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

  • Viewing 15 posts - 541 through 555 (of 1,419 total)