Forum Replies Created

Viewing 15 posts - 316 through 330 (of 1,413 total)

  • Reply To: average of percentage

    By default SQL Server performs integer division on integers which means decimal remainders are truncated.  The DB Engine switches  to floating point math if the denominator of a fraction is...

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

  • Reply To: Why do Sql Server In operator behaves differently and return nothing?

    Sorry  not able to replicate the issue.  The OP code relies on implicit conversion between INT and NVARCHAR which generally works but is an error prone (and awful for the...

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

  • Reply To: Are the posted questions getting worse?

    TRIGGER_NESTLEVEL?  I usually try to persuade novices out of it.  Maybe the non-INSTEAD OF triggers could ask themselves: "Have I been executed at an inappropriate nest level?"

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

  • Reply To: should atemp table be used from looping even when single table is used in a loop

    The textbooks say writing your own loops in relational database code is something to be avoided.  Are you sure it's necessary to write loops?

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

  • Reply To: Are the posted questions getting worse?

    Jeff Moden wrote:

    SGAB, does any one have a decent example of an Instead Of Update trigger that will handle more than one bloody row at a time and also ONLY update...

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

  • Reply To: Get Date Monday Show results for weekend and then else 24 hours

    To generate sample data you could use a Tally table and calculate a datetime column.  This generates 400 rows and calculates a column 'sample_dt' which starts with the current...

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

  • Reply To: Split string

    Interesting and much appreciated.  Happy Thanksgiving!

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

  • Reply To: Split string

    If you load up one of the strings with a bunch of commas it causes an error afaik.  JSON doesn't care how many commas in a row.  A tiny point...

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

  • Reply To: Split string

    Comma is not an escape character in JSON (towards the bottom of the page) 😉

    https://www.json.org/json-en.html

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

  • Reply To: No PK on any tables - Need that to enable Change Tracking on SQL Server

    The "application" is out of support and yet the database is separate and updatable?  If at all possible I wouldn't touch a single thing.   If something breaks... better to treat...

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

  • Reply To: Split string

    Jeff's code seems to generate primary keys and produces the correct output afaik.  Creating foreign keys should be straightforward for the OP.  The split could be accomplished with OPENJSON without...

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

  • Reply To: hex conversion

    Why does this make sense?  CONVERT using style 2 seems to convert to text and removes the leading '0x'

    select Modelnameid origignal
    ,cast(SUBSTRING(Modelnameid...

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

  • Reply To: How to compare average prices of weekday vs weekend

    A good first step could be to run this code

    select datepart(weekday, cast(getdate()+nums.n as date)) day_of_week_number, 
    datename(weekday, cast(getdate()+nums.n as date)) day_of_week
    from...

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

  • Reply To: How to summarise values in hierarchies

    Maybe you're looking for the SUM OVER the volume partitioned by the 'parent_id' column but which column is appropriate to ORDER BY?  If ORDER BY the 'filter_path' column it causes...

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

  • Reply To: Adding of single quote in a string

    Phil Parkin wrote:

    The enable_ordinal argument for STRING_SPLIT is not implemented in 2019.

    It's true.  It's available in Azure SQL compatibility level 150 (and above) and SQL Server 2022.  There are alternatives such...

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

Viewing 15 posts - 316 through 330 (of 1,413 total)