Created
October 9, 2018 08:48
-
-
Save KalinovDmitri/ca573622d7fd14d85fd8e3305b0b23f7 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
DECLARE @kindId UNIQUEIDENTIFIER = '2E42CD9A-66FA-471E-BA75-5A74D36E05D3'; -- place target Kind here | |
DECLARE @folderId UNIQUEIDENTIFIER = 'D0134C4C-2B33-45BC-9B3A-EEFCEF855C87'; -- place target Folder here | |
SELECT | |
[DocMainInfo].[InstanceID] AS [CardID], | |
[InstanceDates].[CreationDateTime], | |
@folderId AS [FolderID] | |
FROM [dbo].[CardDocument::MainInfo] AS [DocMainInfo] | |
INNER JOIN [dbo].[dvsys_instances_date] AS [InstanceDates] ON ([InstanceDates].[InstanceID] = [DocMainInfo].[InstanceID]) | |
INNER JOIN [dbo].[CardDocument::System] AS [DocSystemInfo] ON ([DocSystemInfo].[InstanceID] = [DocMainInfo].[InstanceID]) | |
WHERE | |
[DocSystemInfo].[Kind] = @kindId | |
AND DATEDIFF(SECOND, [InstanceDates].[CreationDateTime], GETDATE()) <= 300 | |
AND NOT EXISTS | |
( | |
SELECT 1 | |
FROM [dbo].[FoldersCard::Shortcuts] AS [Shortcuts] | |
WHERE [Shortcuts].[ParentRowID] = @folderId AND [Shortcuts].[CardID] = [DocMainInfo].[InstanceID] | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment