Created
October 3, 2014 12:21
-
-
Save contensis/09381c0e203806d37c3c to your computer and use it in GitHub Desktop.
T-SQL for creating a bespoke report to show content ordered by modified date
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
GO | |
/****** Object: StoredProcedure [dbo].[bp_ContentUpdatedAndByWhom] Script Date: 03/10/2014 12:57:18 ******/ | |
SET ANSI_NULLS ON | |
GO | |
SET QUOTED_IDENTIFIER ON | |
GO | |
ALTER PROCEDURE [dbo].[bp_ContentUpdatedAndByWhom] | |
AS | |
BEGIN | |
SET NOCOUNT ON; | |
select * from ( | |
(select | |
WPV_Label as 'Name', | |
WPV_Title as 'Title', | |
F_Path as 'Path', | |
LTRIM(RTRIM(US_Firstname + ' ' + US_Surname)) as 'Updated By', | |
WPV_Modified as 'Updated', | |
WP_ID as ItemID, | |
WPV_ID as ItemVersionID, | |
2 as ItemWorkflowType, | |
0 as ItemContentTypeID, | |
F_ID as ItemFolderID, | |
WPV_Label as ItemLabel, | |
WPV_Title as ItemTitle, | |
F_Path as ItemPath, | |
case when WP_Status & 0x01 = 0x01 then 1 else 0 end as ItemHasEditVersion, | |
case when WP_Status & 0x02 = 0x02 then 1 else 0 end as ItemHasLiveVersion, | |
0 as ItemWorkflowActionID, | |
0 as ItemWorkflowUserID, | |
WP_Created as ItemDateStamp, | |
case when WP_Status & 0x04 = 0x04 then 1 else 0 end as IsArchived, | |
case when WP_Status & 0x08 = 0x08 then 1 else 0 end as IsDeleted, | |
WPV_IncludeInAtoZ as IncludeInAtoZ, | |
WPV_IncludeInMenu as IncludeInMenu, | |
WPV_IncludeInSearch as IncludeInSearch, | |
WPV_IncludeInSitemap as IncludeInSitemap, | |
WPV_Created as ItemCreatedDate, | |
WPV_MenuLabel as ItemMenuName, | |
WPV_Modified as ItemModifiedDate, | |
0 as ItemSize, | |
WPV_Version as ItemVersion | |
from WP_Webpages | |
join WPV_WebPageVersion on WPV_WebPageVersion.WPV_ID = WP_Webpages.WP_LatestVersionID | |
join F_Folders on F_Folders.F_ID = WP_Webpages.WP_F_ID | |
join US_Users on US_Users.US_ID = WPV_WebPageVersion.WPV_ModifiedBy | |
where WP_Deleted = 0 | |
) | |
union | |
(select | |
CV_Label as 'Name', | |
CV_Title as 'Title', | |
F_Path as 'Path', | |
LTRIM(RTRIM(US_Firstname + ' ' + US_Surname)) as 'Updated By', | |
CV_Modified as 'Updated', | |
C_ID as ItemID, | |
CV_ID as ItemVersionID, | |
0 as ItemWorkflowType, | |
C_CT_ID as ItemContentTypeID, | |
F_ID as ItemFolderID, | |
CV_Label as ItemLabel, | |
CV_Title as ItemTitle, | |
F_Path as ItemPath, | |
case when C_Status & 0x01 = 0x01 then 1 else 0 end as ItemHasEditVersion, | |
case when C_Status & 0x02 = 0x02 then 1 else 0 end as ItemHasLiveVersion, | |
0 as ItemWorkflowActionID, | |
0 as ItemWorkflowUserID, | |
C_Created as ItemDateStamp, | |
case when C_Status & 0x04 = 0x04 then 1 else 0 end as IsArchived, | |
case when C_Status & 0x08 = 0x08 then 1 else 0 end as IsDeleted, | |
CV_IncludeInAtoZ as IncludeInAtoZ, | |
CV_IncludeInMenu as IncludeInMenu, | |
CV_IncludeInSearch as IncludeInSearch, | |
CV_IncludeInSitemap as IncludeInSitemap, | |
CV_Created as ItemCreatedDate, | |
CV_MenuLabel as ItemMenuName, | |
CV_Modified as ItemModifiedDate, | |
0 as ItemSize, | |
CV_Version as ItemVersion | |
from C_Content | |
join CV_ContentVersion on CV_ContentVersion.CV_ID = C_Content.C_LatestVersionID | |
join F_Folders on F_Folders.F_ID = C_Content.C_F_ID | |
join US_Users on US_Users.US_ID = CV_ContentVersion.CV_ModifiedBy | |
where C_Deleted = 0 | |
) | |
) Items | |
order by | |
Updated desc, | |
[Path], | |
Name | |
END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment