Last active
October 19, 2024 18:25
-
-
Save wullemsb/77e69acf7156137ecdd1d3349a9f481c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE PROCEDURE [dbo].[READBYKEYS] ( | |
@list NVARCHAR(MAX), | |
@user NVARCHAR(50), | |
) | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
-- Temporary table to hold IDs from the list | |
DECLARE @hastable TABLE (Id BIGINT); | |
-- Split the input list and insert into the temporary table | |
INSERT INTO @hastable (Id) | |
SELECT TRY_CAST(value AS BIGINT) | |
FROM STRING_SPLIT(@list, ',') | |
WHERE TRY_CAST(value AS BIGINT) IS NOT NULL; | |
//We should log every attempt to query this datasource | |
INSERT INTO AUDIT_LOG (@user, @list) | |
SELECT RR_DATA.ID, NR_RR | |
FROM RR_DATA | |
INNER JOIN @hastable ha ON RR_DATA.ID = ha.Id; | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment