Viewing 15 posts - 511 through 525 (of 1,391 total)
What about a potential negative sign? You gonna add a phony replacement in for that too?
Good idea! Yes, I added ('-', '-') and it works with negative integers now...
October 25, 2021 at 7:07 pm
To review, the table definition provided by the OP
CREATE TABLE dbo.IntChange (NumericValue INT)
INSERT INTO dbo.IntChange
VALUES (15697)
,(876)
,(1452)
,(3374)
,(894)
,(84516)
You have some reason to believe the future universe of possible inputs...
October 25, 2021 at 6:52 pm
Wow all that. Ok maybe something like this
select IcC.NumericValue,
stuff((select ''+v.repl
...
October 25, 2021 at 6:24 pm
You feel misled? It's an axiomatic statement of equivalency
October 25, 2021 at 5:30 pm
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...
October 25, 2021 at 4:44 pm
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
October 25, 2021 at 3:51 pm
Sorry it's not clear to me. Maybe a more detailed example could help
October 24, 2021 at 5:57 pm
What are the expected Usage and Result values for each row of the @t table?
October 24, 2021 at 4:40 pm
maybe something like this
select ic.NumericValue,
stuff((select '' + v.repl
...
October 24, 2021 at 12:59 pm
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
October 23, 2021 at 4:29 pm
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...
October 23, 2021 at 2:20 pm
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...
October 23, 2021 at 12:21 pm
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
October 22, 2021 at 12:40 pm
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]
/**********************************************************************************************************************
...
October 21, 2021 at 3:18 pm
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...
October 20, 2021 at 1:38 pm
Viewing 15 posts - 511 through 525 (of 1,391 total)