Skip to content

Instantly share code, notes, and snippets.

@rdsaunders
Last active March 14, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rdsaunders/e56bcc66b39e27a4277e840da071dfe2 to your computer and use it in GitHub Desktop.
Save rdsaunders/e56bcc66b39e27a4277e840da071dfe2 to your computer and use it in GitHub Desktop.
Set the Content Owner to the user who most recently modified the content
-- Set the Content Owner to the user who most recently modified the content
update cv
set cv.CV_Owner = cv.CV_ModifiedBy
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 = cv.CV_ModifiedBy
where cv.CV_Owner is null
and cv.CV_ModifiedBy > 0
and (
cv.CV_ID = c.C_LiveVersionID
or cv.CV_ID = c.C_EditVersionID
)
update wpv
set wpv.WPV_Owner = wpv.WPV_ModifiedBy
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 = wpv.WPV_ModifiedBy
where wpv.WPV_Owner is null
and wpv.WPV_ModifiedBy > 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