Skip to content

Instantly share code, notes, and snippets.

@rdsaunders rdsaunders/content-owner-creator.sql Secret
Last active Mar 14, 2017

Embed
What would you like to do?
Set the content owner of all content items to the creator of the content.
-- Set the Content Owner to the user who created the content
update cv
set cv.CV_Owner = c.C_CreatedBy
from CV_ContentVersion cv
join C_Content c
with (nolock)
on c.C_ID = cv.CV_C_ID
join US_Users u
with (nolock)
on u.US_ID = c.C_CreatedBy
where cv.CV_Owner is null
and c.C_CreatedBy > 0
and (
cv.CV_ID = c.C_LiveVersionID
or cv.CV_ID = c.C_EditVersionID
)
update wpv
set wpv.WPV_Owner = wp.WP_CreatedBy
from WPV_WebPageVersion wpv
join WP_Webpages wp
with (nolock)
on wp.WP_ID = wpv.WPV_WP_ID
join US_Users u
with (nolock)
on u.US_ID = wp.WP_CreatedBy
where wpv.WPV_Owner is null
and wp.WP_CreatedBy > 0
and (
wpv.WPV_ID = wp.WP_LiveVersionID
or wpv.WPV_ID = wp.WP_EditVersionID
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.