Today I had to take the back-up off a live site and restore it on the staging server. However I had to remove all Umbraco members and thought it'd be easier to do that with SQL script than API.
Despite Googling to find a firm solution (SQL script), I couldn't find one, so I decided to share this code in case anyone else wanted to delete all Umbraco members with SQL script rather than API.
This what I have come up with so far, and it seems to have removed all the members, but please leave a comment if you think there is a better way of doing this, or if any other data needs to be removed from any other table.
1
2
3
4
5
6
7
8
9
10
11
|
delete
from
cmspropertydata
where
cmsPropertyData.contentNodeId
in
(
select
nodeid
from
cmsMember)
delete
from
dbo.cmsContentVersion
where
ContentId
in
(
select
nodeId
from
cmsMember)
delete
from
dbo.cmsMember2MemberGroup
where
member
in
(
select
nodeId
from
cmsMember)
delete
from
cmsContentXml
where
nodeId
in
(
select
nodeId
from
cmsMember)
delete
from
cmsPreviewXml
where
nodeId
in
(
select
nodeId
from
cmsMember)
create
table
#CmsMemberIds ( nodeId
int
)
insert
into
#CmsMemberIds
select
nodeId
from
cmsMember
delete
from
cmsMember
delete
from
cmsContent
where
nodeId
in
(
select
nodeid
from
#CmsMemberIds)
delete
from
dbo.umbracoNode
where
id
in
(
select
nodeId
from
#CmsMemberIds)
drop
table
#CmsMemberIds
|