Viewing 15 posts - 361 through 375 (of 1,464 total)
Man! You are so right! This is going to be totally liberating for me!
To commemorate my new found joyous method for doing my job without being a bottleneck,...
January 30, 2020 at 6:01 am
To add to what Grant has stated, I agree that "new" voices are a bonus on any forum but I have seen some "new" people come in with...
January 30, 2020 at 4:20 am
My apologies. I wanted to Quote Jeff's answer, but accidentally hit the REPORT link instead. Are Admins/Mods able to please undo my error
This was the post (copied from my mail)
To...
January 30, 2020 at 4:18 am
Declare @DBID Int Set @DBID = DB_ID ()
Checkpoint
DBCC DROPCLEANBUFFERS WITH NO_INFOMSGS
DBCC FLUSHPROCINDB (@DBID) WITH NO_INFOMSGS
That will clear execution plans and data from memory, which would...
January 29, 2020 at 2:00 pm
NOLOCK and READUNCOMMITTED only affect reads. This proc is doing inserts and updates, so it MAY have an impact if all other procs use NOLOCK/READ UNCOMMITTED.
My gut says that changing...
January 20, 2020 at 4:24 am
You are formatting your input string with style 101, and then asking SQL to interpret it as style 100.
You need to match your style to your input string
January 14, 2020 at 5:20 pm
Take a look at the SQL CONVERT function for formatting the dates for display.
But PLEASE PLEASE PLEASE do not save the dates as varchar. You will be opening yourself...
January 14, 2020 at 4:42 pm
I like the simplicity of finding the February 29 dates, then subtracting that DesNorton posted. But it didn't calculate correctly when I used the start date of 01/01/2019 end...
January 13, 2020 at 5:07 pm
This can be made more dynamic with a function that gets the FEB29 days
CREATE FUNCTION dbo.GetLeapYearDates(@Date1 AS date, @Date2 AS date)
RETURNS TABLE WITH SCHEMABINDING
AS
RETURN
WITH
...
January 11, 2020 at 7:26 am
If something isn't a set, it often helps to turn it into a set. Here's an example:
DECLARE @val1 nvarchar(40) = 'Hello';
DECLARE @val2 nvarchar(40) = 'Treacle';
DECLARE @val3...
January 11, 2020 at 6:52 am
Here is another option
DECLARE @val1 nvarchar(40) = 'Hello';
DECLARE @val2 nvarchar(40) = 'Treacle';
DECLARE @val3 nvarchar(40) = NULL;
DECLARE @val4 nvarchar(40) = 'Rhubarb';
DECLARE @nth int = 2;
WITH cteNonNullData AS (
...
January 11, 2020 at 6:50 am
This sounds very much like a homework or interview question.
I would suggest researching the TOP key word
January 8, 2020 at 4:38 am
Your problem is the "," before the "ORDER BY" in your "OVER" clauses
WITH T1 (ID1, ID2)
AS
(
SELECT 1,1 UNION ALL
SELECT 1,1 UNION ALL
SELECT 1,1 UNION ALL
SELECT 1,2
)
SELECT *,
RANK()...
January 8, 2020 at 4:35 am
You could also do it without the CTE
SELECT Q.Quater as 'Quarter', Q.Year as 'Year'
FROM Quaters as Q
WHERE Q.Year = DATEPART(YEAR, GETDATE())
AND Q.Quater =...
January 2, 2020 at 8:46 am
Depending on your indexes, this may help
; WITH CTE AS
(
SELECT DATEPART(QUARTER, GETDATE()) as 'Quarter', DATEPART(YEAR, GETDATE()) as 'Year'
)
SELECT CTE.Quarter, CTE.Year
FROM CTE
INNER JOIN Quaters as Q
...
January 2, 2020 at 7:43 am
Viewing 15 posts - 361 through 375 (of 1,464 total)