Created
August 22, 2013 04:50
-
-
Save tomfulton/6303334 to your computer and use it in GitHub Desktop.
Replace Umbraco Property Data
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
/* | |
From: http://our.umbraco.org/forum/developers/api-questions/6327-Search-and-replace-property-value#comment23622 | |
*/ | |
--BEGIN TRAN; | |
DECLARE @rootNodeId NVARCHAR(50); | |
SET @rootNodeId = '1050'; | |
DECLARE @search NVARCHAR(50); | |
SET @search = 'Person A'; | |
DECLARE @replace NVARCHAR(50); | |
SET @replace = 'Person B'; | |
UPDATE | |
cmsPropertyData | |
SET | |
dataNvarchar = REPLACE(dataNvarchar, @search, @replace), | |
dataNtext = CAST(REPLACE(CAST(dataNtext as NVARCHAR(4000)), @search, @replace) AS NTEXT) | |
FROM | |
cmsPropertyData AS d | |
INNER JOIN umbracoNode AS n ON n.id = d.contentNodeId | |
WHERE | |
n.path LIKE ('-1,%' + @rootNodeId + '%') | |
AND | |
( | |
d.dataNvarchar LIKE ('%' + @search + '%') | |
OR | |
d.dataNtext LIKE ('%' + @search + '%') | |
) | |
; | |
--ROLLBACK TRAN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment