Viewing 15 posts - 2,791 through 2,805 (of 7,609 total)
select * from table where sportyear=DATEADD(YEAR, -1, @year)
June 14, 2019 at 2:11 pm
Please be more specific on "Does not work" for Q.ArrangementType. In general you should have no problem referencing columns in the view in a NOT EXISTS, so some other error...
June 13, 2019 at 2:01 pm
If you're truly on SQL 2016+, as you said, you can use SESSION_CONTEXT, as below.
It's easier if the tables have the exact same structure, but we could "fudge" around it...
June 12, 2019 at 6:22 pm
Oops, yep, sorry. A copy/paste where I accidentally left the ", 0" at the end.
June 12, 2019 at 5:33 pm
Something along these lines:
Declare @jan01 date
Set @jan01 = Dateadd(Year, Datediff(Year, 0, GETDATE()), 0)
select
Case Left(PeriodID, 3)
When 'Jan' THEN Dateadd(Day, -1, Dateadd(Month, 1, @jan01), 0)
When 'Feb' THEN Dateadd(Day, -1,...
June 12, 2019 at 4:08 pm
Use just one date for each month; in keeping with "standard" practice, I use the first of the month.
Also, you must remove H.Quantity from the GROUP BY.
select...
June 12, 2019 at 2:11 pm
Again, MS is following the relational model, where a set does not have a defined order. That may be fine theoretically, but in the real world we often do need...
June 11, 2019 at 7:42 pm
Here's another alternative to splitting, to show how CROSS/OUTER APPLY can assign alias names to computed values that can be used in subsequent APPLYs and in the SELECT itself, without...
June 11, 2019 at 2:23 pm
Presumably MS is following relational theory, where the order of a set doesn't matter.
But, in the real world, the order often does matter a lot, especially when the set has...
June 10, 2019 at 9:01 pm
Note that you don't have to drop the index and re-create it.
Instead you can DISABLE it, then REBUILD it.
ALTER INDEX no_dups_index ON dbo.your_table DISABLE;
UPDATE your_table
SET ... = ... + 5
/*WHERE...
June 10, 2019 at 4:38 pm
SELECT MonthCount AS [Total Entries],
DATENAME(MONTH, RecvdMonth) + ' ' + CAST(YEAR(RecvdMonth) AS varchar(4)) AS MONTH
FROM (
SELECT
DATEADD(MONTH, DATEDIFF(MONTH, 0, RecvdDate), 0) AS RecvdMonth,
COUNT(ID) AS...
June 6, 2019 at 3:03 pm
You could do this using a stored procedure. The structure can be returned by the query itself, you don't have to pre-define it. In theory there are potential SQL injection...
June 5, 2019 at 8:53 pm
I can see that, so another try with the code again. If I've done dup posts, admins please delete the extraneous post(s).
I've been extremely busy and so haven't had time...
June 3, 2019 at 5:56 pm
I can't see my own last post(s), so I don't know if it(they) showed up or not.
June 3, 2019 at 5:55 pm
I'd urge you not to use a temp table for that. If SQL goes down during the processing, you'll never be able to determine what the original key values were.
June 3, 2019 at 5:18 pm
Viewing 15 posts - 2,791 through 2,805 (of 7,609 total)