Viewing 15 posts - 466 through 480 (of 4,087 total)
This gives the expected results, but it may not handle unexpected data such as PayHours being inconsistent for a given employee/date.
SELECT ROW_NUMBER() OVER(ORDER BY m.EmployeeNum, m.LaborDate, GROUPING(m.ID),...
July 29, 2019 at 9:47 pm
The following code seems simpler and easier to understand to me.
SELECT *
FROM #tsttable AS t
WHERE t.cid NOT IN (100, 111)
OR t.ccode NOT IN ('out', 'outa', 'stt', 'cnty')
Using...
July 26, 2019 at 9:39 pm
If you knew the items were fixed you could get them back using a PIVOT query:
SELECT *
FROM #testtbl src
PIVOT (MAX(Item) FOR Item IN (XX,...
July 26, 2019 at 3:17 pm
Have you looked at sub-reports?
Drew
July 24, 2019 at 10:34 pm
Use a tally table. Here I've used an inline tally table.
INSERT #Child (PID, PName)
SELECT
p.PID
,p.PName
FROM #Parent p
CROSS APPLY (VALUES(1), (2), (3), (4)) t(n)
WHERE p.NoOfChildrenRecs >= t.n
Drew
July 24, 2019 at 10:30 pm
Also they have to be in two different data sets so it wont just give me the same name again. if you have any ideas where to start that...
July 24, 2019 at 3:20 pm
Last but certainly not least, there is no way that I'd ever include spaces or other special characters in the columns so as to make them require brackets....
July 24, 2019 at 3:18 pm
Also, this is just part of the code and when I am running the complete Stored procedure I am getting this particular error: Msg 207, Level 16, State...
July 23, 2019 at 3:27 pm
This sounds like homework. You're better off attempting this yourself.
Drew
July 22, 2019 at 9:34 pm
A couple of other points.
July 22, 2019 at 3:23 pm
EXEC PI_Generate_Alternative_Schedule_List 'AD42870',,'UCLA'Msg 102, Level 15, State 1, Line 92
Incorrect syntax near ','.
This is the source of your error. The procedure requires three...
July 19, 2019 at 8:20 pm
There are so many issues with this code, it's hard to know where to start. Since you failed to provide the error message, it's even more difficult.
July 19, 2019 at 8:08 pm
Agree with @Taps. LEAD()
or LAG()
is the best option here. Those functions were specifically designed to handle these types of queries.
Drew
July 19, 2019 at 2:03 pm
I've created some test code, not realistic, but the CTE with SELECT TOP(1) is over ten times faster, though has more logical reads.
I also notice that...
July 10, 2019 at 10:12 pm
Viewing 15 posts - 466 through 480 (of 4,087 total)