Viewing 15 posts - 646 through 660 (of 7,616 total)
SELECT key
FROM dbo.your_table_name_here
GROUP BY key
HAVING MAX(CASE WHEN type = 'COLL' AND subtype = 'MOD' THEN 1 ELSE 0 END) = 1 AND
MAX(CASE WHEN...
September 14, 2022 at 7:46 pm
I don't think so. PIVOT works on only one column at a time, IIRC. A cross-tab is almost certainly the best method here.
September 14, 2022 at 7:12 pm
Great point; sorry, I accidentally left out that "current year" requirement.
September 14, 2022 at 2:22 pm
If you just want the MemberID, then as below. Of course you can adjust the query against the cte to pull more columns if you want them. Either way, I...
September 13, 2022 at 11:12 pm
You want the unique clustered index on ( date_, ID_vard ), assuming that you do primarily query the table by date_, and not on just ID_vard.
Can you clarify...
September 13, 2022 at 4:08 pm
You want the unique clustered index on ( date_, ID_vard ), assuming that you do primarily query the table by date_, and not on just ID_vard.
September 13, 2022 at 2:48 pm
You likely should encode the room name for internal use -- I'd probably call it "room_code" -- but you'll need at least a smallint, and I'd probably just "byte" the...
September 12, 2022 at 8:04 pm
I am going to add this statement at the top of the SP, it will prevent or minimize deadlocks:
SET DEADLOCK_PRIORITY HIGH
No, it won't. Instead, it will force SQL to kill...
September 12, 2022 at 7:51 pm
Change the WHERE conditions to match:
...
WHERE ControlPointName NOT LIKE 'WD%' AND ControlPointName NOT LIKE 'WM%' and --<<-- "day = " removed
( (month = @month and year = @year...
September 8, 2022 at 11:38 pm
I think it would be as below. You must put the partition values in alpha order.
CREATE PARTITION FUNCTION PF_Postcode(varchar(100))
AS RANGE LEFT FOR VALUES
(
'7420_FMIL',
'C7_4JM',
'ND8_1ZE'
)
September 8, 2022 at 11:35 pm
Hi Scott, getting an error on Column not found in this piece;
MAX(CASE WHEN month = @month AND year = @year THEN ControlPointName END)
That one is part of the...
September 8, 2022 at 4:33 pm
Run CHECKDB to determine errors. Backup the existing db to make sure you'll never be worse off than you are now.
If an error is in a non-clustered index, simply drop...
September 8, 2022 at 4:30 pm
I think this will do it, but I have not tested it.
SELECT
MAX(CASE WHEN month = @month AND year = @year THEN ControlPointName END)...
September 8, 2022 at 4:13 pm
I'd strongly urge you to avoid a tinyint. Mainly because the room number is "904", not just 4 (and not 94). If you think about it, "room 4"...
September 7, 2022 at 4:25 pm
;WITH cte_test_data AS (
SELECT CAST('163 Bathroom {BATHROOM CLEANING}{2.5%}' AS varchar(100)) AS string
)
SELECT
string AS original_string,
CASE WHEN...
September 7, 2022 at 4:18 pm
Viewing 15 posts - 646 through 660 (of 7,616 total)