Hello Everyone,
Please help me with this issue,
I've to write a stored procedure which will disable all the database user(not the admins like - sa) from 8.30 am to 7:00 pm.
If anyone wants more details on this please feel free leave your question.
Thank you

Ramachandran MRank #2,660 · 522 reputationPosted Dec 8, 2019, 9:15 PM EST
AS
BEGIN
DECLARE @TimeHour AS INT
DECLARE @TimeMinites AS INT
SET @TimeHour = (SELECT FORMAT(getdate(), 'HH'))
SET @TimeMinites = (SELECT FORMAT(getdate(), 'mm'))
PRINT @TimeHour
PRINT @TimeMinites
IF((@TimeHour > 7 AND @TimeMinites > 30 ) AND (@TimeHour < 19 AND @TimeMinites < 0 ))
BEGIN
REVOKE CONNECT FROM "sa"
END
ELSE
BEGIN
GRANT CONNECT TO "sa"
END
END
Ramachandran MRank #2,660 · 522 reputationPosted Dec 8, 2019, 10:17 PM EST
ALTER LOGIN login_name DISABLE
END
ELSE
BEGIN
ALTER LOGIN login_name ENABLE
Ritendra MallRank #5,080 · 312 reputationPosted Dec 8, 2019, 10:55 PM EST
@Ramachandran M
Ritendra MallRank #5,080 · 312 reputationPosted Dec 9, 2019, 1:27 AM EST
@Ramachandran M
Ramachandran MRank #2,660 · 522 reputationPosted Dec 9, 2019, 1:33 AM EST
Ritendra MallRank #5,080 · 312 reputationPosted Dec 9, 2019, 2:13 AM EST
Ritendra MallRank #5,080 · 312 reputationPosted Dec 9, 2019, 9:11 PM EST