Viewing 15 posts - 2,266 through 2,280 (of 7,614 total)
Here's how to calc the new selling price for any new net margin. (I always did love algebra.)
Edit: I didn't see Des's until after I had posted mine.
October 1, 2020 at 4:07 pm
Hmm, that task sounds like it should be a single INSERT statement, which means SQL should resolve GETDATE() only once. Therefore it seems as if your trigger is using a...
October 1, 2020 at 9:57 am
You don't need a calendar table for this. Also, note that the Friday check below works under any/all DATEFIRST settings. DATEFIRST is not something you want to change in your...
October 1, 2020 at 9:50 am
SELECT DATEADD(DAY, (@DaysDifference + 6) / 7 * 7, @OriginalFirstStartDate)
September 29, 2020 at 9:04 pm
The UPDATE "doesn't work" because since reserve is null, it will stay null, even though you think you "added 1 to it". NULL + 1 = NULL.
If you prefer, you...
September 29, 2020 at 8:58 pm
SELECT
Id,
MIN(CASE WHEN StatusName = 'Draft' THEN CreatedOn ELSE NULL END) AS Draft,
MIN(CASE WHEN StatusName =...
September 29, 2020 at 4:12 am
Would you provide the actual T-SQL statement you were attempting to execute?
September 28, 2020 at 3:13 pm
The fix is:
Select STUFF((Select Distinct + ', '+ CONVERT(varchar(20), A1.date, 105)
...
Since A1.date is a datetime, which has a higher precedence than varchar, SQL is attempting to add ',' to the...
September 28, 2020 at 7:29 am
Frankly the percentages from an estimated query plan are often so inaccurate they should just be ignored.
Look at the actual operations in the query plan, not the percentages.
September 28, 2020 at 7:23 am
Restore old msdb backup(s) to a different db name. We typically add '_' and the date of the backup to the name. Something like this:
RESTORE DATABASE msdb_20190915 FROM DISK =...
September 25, 2020 at 3:55 pm
As to the actual code, a more straightforward way is to CAST to date, which will perforce remove the time value, then CAST back to datetime (this probably isn't strictly...
September 25, 2020 at 3:48 pm
Getting rid of NOLOCK will only hurt performance, never help it. That's not an endorsement of nor objection to NOLOCK in these specific statements, just a general statement of fact. ...
September 22, 2020 at 7:17 pm
Quote: "We couldn't do much about the database design as it is a vendor specific database."
Understood. Lol, the only thing potentially worse than a "programmer (non)'designed' table" is a "vendor...
September 22, 2020 at 3:38 pm
Try below. Sorry, I don't have time right now to explain the code.
SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
GO
CREATE TRIGGER [dbo].[Dupl_Rec]
ON [dbo].[Table A]
AFTER INSERT
AS
SET NOCOUNT ON;
INSERT INTO dbo.Audit...
September 21, 2020 at 5:21 pm
According to your table structure, there is no index on [MULE_BATCH_ID]. This means that SQL has to do a table scan to find the record.
You are doing a...
September 21, 2020 at 2:47 pm
Viewing 15 posts - 2,266 through 2,280 (of 7,614 total)