Viewing 15 posts - 241 through 255 (of 4,087 total)
I'm not sure if this is more efficient, but this also works.
SELECT PackageName = 'Project'
,ItemType = 'Project Parameter'
...
May 27, 2020 at 1:46 pm
This sounds like something that should be done in the presentation layer, not the data layer. This is easy in SSRS, for example.
Drew
May 18, 2020 at 1:46 pm
You have your dates switched in the DATEDIFF function. It should be DATEDIFF(DAY, LAG(...), visit_date_01)
. Or you should be using LEAD()
instead of LAG()
.
Drew
May 4, 2020 at 4:00 pm
Use the TRY_CONVERT()
or the TRY_CAST()
function. They will return the value if it can convert/cast it, and will return NULL otherwise.
Drew
May 4, 2020 at 1:40 pm
Certain windowed functions that use an ORDER BY
clause require a frame. If you do not provide a frame it uses the default RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
. ...
April 30, 2020 at 6:54 pm
First, most people are hesitant to open attached files from random strangers on the net. You should provide scripts using the {;} Insert/edit code sample
button just above the text...
April 29, 2020 at 8:37 pm
And why does the col2 value switch from ab
to dd
on 08/04/2020?
It looks like you want a DENSE_RANK()
, but the exact details depend on your answer to Phil`s question.
Drew
April 29, 2020 at 7:13 pm
Based on Neil's sample data, here is a first attempt at a query.
SELECT c.Name, c.NameKey, c.SaleDate, c.SaleQuantity, c.CurrentCategory, h.Value
FROM #Current c
OUTER APPLY
(
SELECT TOP(1) *
FROM #History h
WHERE h.NameKey...
March 13, 2020 at 7:17 pm
You've been around long enough to know that you should provide sample data and expected results.
Drew
March 13, 2020 at 7:07 pm
A picture of your data is worthless. You need to supply actual data by supplying a script using the {;} Insert/edit code sample
to do the following.
March 13, 2020 at 2:16 pm
We don't have enough information to tell you exactly what the problem is, but the error message gives you a LOT of information.
dbo.ItemDetail
has a primary key...February 28, 2020 at 7:00 pm
If there are no updates (impossible without a key) or deletes, I would suggest not using MERGE, but INSERT:
INSERT target (cols)
SELECT cols FROM source
WHERE NOT EXISTS...
February 27, 2020 at 3:48 pm
Please do not cross post. Please respond on this thread https://www.sqlservercentral.com/forums/topic/need-help-parsing-xml-3#post-3727725
Drew
February 21, 2020 at 3:48 pm
Sometimes a backslash is used to insert a literal character. It looks like whatever produced this XML hypercorrected and used \"
to insert a literal double quote ("
) when it...
February 21, 2020 at 3:47 pm
The issue that you're running into is that the two separate queries have different criteria and you aren't taking that into account when you are combining them into one query. ...
February 12, 2020 at 9:26 pm
Viewing 15 posts - 241 through 255 (of 4,087 total)