Viewing 15 posts - 241 through 255 (of 1,390 total)
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...
March 23, 2023 at 6:28 pm
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,
...
March 23, 2023 at 3:06 pm
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
...
March 23, 2023 at 1:42 pm
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...
March 23, 2023 at 1:01 pm
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...
March 23, 2023 at 12:58 pm
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...
March 10, 2023 at 7:12 pm
I don't think calling complicated
string_split
andstring_agg
functions will be more efficient than calling simple string functions.
Maybe so. Can your chatbot make the case for it? Splitting and...
March 10, 2023 at 5:53 pm
Imo davidandrews13 has the right idea. In SQL 2022
select string_agg(sv.[value], ' ') within group (order by sv.ordinal) first2_in_order
from #temp t
cross apply (select...
March 10, 2023 at 5:03 pm
Could be a type mismatch due to the search string not being specified with the Unicode prefix N'...'
declare @json nvarchar(max)=N'Array ( [error] => Quote not found [module]...
March 9, 2023 at 7:44 pm
Here's an alternative. Is it better, idk
with
gap_cte as (
select *, case when UserTier<>lag(UserTier) over (partition by UserID order by StartDate) then 1...
March 8, 2023 at 11:21 pm
Imo it depends on whether or not Approved is exactly equivalent to Taken. Could a user be officially approved and yet not take the day? If there's an exact equivalency...
March 6, 2023 at 12:59 pm
It could be two similar queries. For the first one maybe you could try something like this. It uses OUTER APPLY but LEFT JOIN would probably also work
March 3, 2023 at 1:19 pm
Good lord. 🙁
It's got to have you wondering, no? Where the line is to be drawn? How many doublings do we have remaining? What really changes because I'm still...
February 19, 2023 at 5:19 pm
Thank you.I am looking select statement
Ok thank you. Still have some questions tho
Example 1:
exec spLiceceQty @Productid=1,@LicenceQty= 10
I want the following result set
1, 2023-02-15 14:47:16.927, 25
Why...
February 19, 2023 at 4:23 pm
What determines the hierarchy of 'LicenceQty' row values from which to begin the subtraction? In the case of ProductID=1 the example appears to apply lifo, "last in, first out", and...
February 19, 2023 at 1:21 pm
Viewing 15 posts - 241 through 255 (of 1,390 total)