Forum Replies Created

Viewing 15 posts - 256 through 270 (of 1,413 total)

  • Reply To: Hierarchy related calculation

    From the tables provided what is the expected result?

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

  • Reply To: How to get top 100 values of a col concatenated in a variable in sqlserver?

    If it were only the 100th row maybe OFFSET paging.  Since it's both the aggregation of the rows as well as the 100th value you could try using ROW_NUMBER in...

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

  • Reply To: Domain Extension Splitting Based on Dot(.)

    Nice one Jeff.  That's a good looking query.  It makes good use of '+'  as the NULL respecting concatenation operator.  My initial thought was to reverse the string and use...

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

  • Reply To: Bad data - updating date from new FK

    All right it sounds tedious.  To differentiate the duplicates you're looking to add 1, 2, 3, ... n hours to the datetime column, EffectiveDate.  Of course, this could create new...

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

  • Reply To: How to add couple more conditions to the query

    Maybe 3 WHERE clause conditions could be sufficient (A and B or C):

    A) the existing criteria

    B) NOT College ID 06 under Municipality 25002

    C) municipal_ID equals 4269005 (which would be inclusive...

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

  • Reply To: Finding duplicates based on count on different fields

    Or it could be 5 or ?

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

  • Reply To: Finding duplicates based on count on different fields

    In conclusion I would recommend a crosstab-type query.  Conventions of language don't always map to relational operators.  And often predictably so.  Language conventions that is.    Are you sure you're...

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

  • Reply To: SSIS C# Script Question

    Just scanning the code and there are nested Try/Catch and a transaction is declared but rollback only appears in 1 of the TRY code blocks.  That's concerning imo.  Could you...

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

  • Reply To: SSIS C# Script Question

    Maybe throw a general exception and write your own error message.  Or the method returns void so maybe just "return;"?

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

  • Reply To: Grouping the first letter in a string

    Per SQL 2022 you could try STRING_SPLIT with the optional ordinal parameter and then recombine using STRING_AGG

    drop table if exists #temp
    go
    select *
    into #temp
    from (values ('First American...

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

  • Reply To: Help with calculating Percentages

    It turns out, upon further review, a non-INT as either the numerator OR the denominator will switch the implicit conversion to NUMERIC.

    select sql_variant_property(1/4, 'basetype') int_int,
    ...

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

  • Reply To: Swapping coordinate pairs round

    Needs the XML trick to reaggregate the string

    declare @string varchar(max)='-0.326548;51.75514;-0.32658;51.75507;-0.326261;51.755;-0.326231;51.75508;-0.326548;51.75514;';

    select *
    from dbo.DelimitedSplit8K_LEAD(@string, ';') ss
    cross apply (values (iif(ss.ItemNumber%2=0, ss.ItemNumber-1, ss.ItemNumber+1))) v(new_seq);

    select stuff((select ' ' + ss.Item
    ...

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

  • Reply To: Help with calculating Percentages

    Instead of dividing by 100 try dividing by 100.0.  With division the implicit type conversion is to INT unless the denominator is non-INT, either NUMERIC or FLOAT.  Also, imo the...

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

  • Reply To: BASE64 Encode and Decode in T-SQL

    For posterity since 2012 the built-in method for converting to base64 is using XML.  This comes up every now and then on SSC.  The only post I could find tho...

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

  • Reply To: First Two Words

    Already had dbo.fnTally.  Here are the results which show 7 or 8 seconds for CHARINDEX and 33+ seconds for STRING_SPLIT.  This is my tiny Azure SQL compatibility level 150 test...

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

Viewing 15 posts - 256 through 270 (of 1,413 total)