Viewing 15 posts - 391 through 405 (of 4,087 total)
You're fixing the wrong problem. The problem here is that you have several pieces of information in one field violating first normal form. Fix the problem at the source rather...
September 25, 2019 at 2:53 pm
There are two solutions CTE or CROSS APPLY.
SELECT DISTINCT
ph.STARTDATE
,ph.SERIALNUMBER
,dc.DESTINATIONGROUP
,pi.PLEDGEID
,pi.INSTALMENTID
,pi.INSTALMENTSTATUS
,pi.DATEDUE
,pi.INSTALMENT
,gd.GADStatus
,ga.GIFTAID
,pi.INSTALMENT + ga.GIFTAID AS TOTALWITHGIFTAID
FROMdbo.PLEDGEHEADER AS ph
INNER JOIN dbo.PLEDGEINSTALMENT AS pi
ON pi.PLEDGEID = ph.PLEDGEID
LEFT OUTER JOIN dbo.GIFTAID_CURRENTDECLARATION AS gd
ON...
September 25, 2019 at 2:31 pm
One should always try to avoid a function on a table column being used for lookup. Therefore, for the last JOIN, do this instead:
LEFT...
September 24, 2019 at 7:07 pm
This seems fairly straightforward. What have you tried and where are you running into problems?
Drew
September 24, 2019 at 6:17 pm
WITH(NOLOCK)
is not a magic "go faster" code. It reads dirty data. You almost certainly don't want to read dirty data when making an update.
Beyond that, there's not a whole...
September 24, 2019 at 3:57 pm
STOP USING CURSORS for simple updates. A previous response showed how to rewrite your original query without using a cursor.
SQL Server is optimized for SET-BASED operations. Using a CURSOR prevents...
September 23, 2019 at 9:56 pm
SSMS is doing a recursive search. I like Redgate's SQL Dependency Tracker.
Drew
September 23, 2019 at 7:33 pm
Date fields do not have formats. Formats are applied by the presentation layer.
If you are storing "dates" in character fields, STOP IT!!!!! You should use the correct data type for...
September 23, 2019 at 4:14 pm
This works, but it would be much simpler with a PK field. (I used all of the fields in place of a PK.)
WITH standardized_mismatches AS
(
SELECT o.*
, ROW_NUMBER()...
September 23, 2019 at 3:32 pm
"most recent" is the smallest date
English must be your second language, because that is certainly not the case.
Drew
September 20, 2019 at 6:23 pm
The ORDER BY entr_dt I think should be ascending. Earlier is better?
If the scores are tied, the person who got it the most recent is shown higher.
I assume...
September 20, 2019 at 4:20 pm
I want to keep the child data but just clear out the parent table.
In that case, I would do a "soft" delete. That is, I would mark the parent...
September 20, 2019 at 4:10 pm
although in your example order 789 contains 3 items, do you only want where there are 2 items? both of which are 1 and 2? or if you have...
September 20, 2019 at 4:07 pm
When requesting help with a problem like this, you need to provide CONSUMABLE DATA and expected results. Text tables are not CONSUMABLE. PICTURES are not DATA. This is how you...
September 20, 2019 at 3:47 pm
Since you didn't provide sample data IN A CONSUMABLE FORMAT, you're getting untested code. This might perform better.
SELECT OrderID
FROM OrderDetails
WHERE ProductID IN (1, 2)
GROUP BY OrderID
HAVING COUNT(DISTINCT...
September 20, 2019 at 1:56 pm
Viewing 15 posts - 391 through 405 (of 4,087 total)