Created
September 8, 2016 01:08
-
-
Save MerrittMelker/24f74b7433675582addc6575481e75dd to your computer and use it in GitHub Desktop.
editing umbraco content from database
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
/****** Script for SelectTopNRows command from SSMS ******/ | |
begin tran | |
declare @start bigint, @end bigint | |
--STUFF ([xml], | |
SELECT | |
@start = PATINDEX('%calendarLink"%', [xml]), | |
@end = PATINDEX('%}%', Substring([xml], PATINDEX('%calendarLink%', [xml]), datalength([xml]))) | |
FROM [cmsContentXml] where nodeId = 1098 | |
select substring([xml], @start + 14, @end) from cmsContentXml where nodeid = 1098 | |
DECLARE @ptrval binary(16); | |
DECLARE @startOffset int, @endOffset int; | |
SET @startOffset = @start + 14; | |
SELECT @ptrval = TEXTPTR([xml]) | |
FROM cmsContentXml | |
WHERE nodeid = 1098 | |
--UPDATETEXT cmsContentXml.[xml] @ptrval @startOffset @end '{"value": [{"caption": "I am a link","link": "http://www.google.com","newWindow": false,"edit": false,"isInternal": false,"type": "external","title": "I am a link"}],"dataTypeGuid": "d1a4fabf-84a5-4168-bbf8-c5c886c5c05e","editorAlias": "calendarLink","editorName": "Calendar Link"}}'; | |
select substring([xml], @start, 400) from cmsContentXml where nodeid = 1098 | |
rollback tran |
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
--declare @start int, @end int | |
--STUFF ([xml], | |
--SELECT top( | |
--from cmspropertydata where contentNodeId = 1098 | |
--and PATINDEX('%calendarLink"%', dataNtext) > 1 | |
--select * from cmsContentXml where nodeid = 1098 | |
-- get latest version of the content | |
--and PATINDEX('%calendarLink"%', dataNtext) > 1 | |
begin tran | |
declare @versionID as uniqueidentifier | |
select top 1 @versionId = versionid from cmsContentVersion where contentid = 1098 order by versiondate desc | |
SELECT * from cmspropertydata where contentNodeId = 1098 and versionId = @versionID and propertytypeid = 51 | |
declare @start int, @end int | |
SELECT | |
@start = PATINDEX('%calendarLink"%', dataNText), | |
@end = PATINDEX('%}%', Substring(dataNText, PATINDEX('%calendarLink%', dataNText), datalength(dataNText))) | |
FROM cmspropertydata where contentNodeId = 1098 and versionId = @versionID and propertytypeid = 51 | |
select substring(dataNText, @start + 14, @end) FROM cmspropertydata where contentNodeId = 1098 and versionId = @versionID and propertytypeid = 51 | |
DECLARE @ptrval binary(16); | |
DECLARE @startOffset int, @endOffset int; | |
SET @startOffset = @start + 14; | |
SELECT @ptrval = TEXTPTR(dataNText) | |
FROM cmspropertydata | |
where contentNodeId = 1098 and versionId = @versionID and propertytypeid = 51 | |
UPDATETEXT cmspropertydata.dataNText @ptrval @startOffset @end '{"value": [{"caption": "I am a link","link": "http://www.google.com","newWindow": false,"edit": false,"isInternal": false,"type": "external","title": "I am a link"}],"dataTypeGuid": "d1a4fabf-84a5-4168-bbf8-c5c886c5c05e","editorAlias": "calendarLink","editorName": "Calendar Link"}'; | |
select substring(dataNText, @start, 2000) from cmspropertydata where contentNodeId = 1098 and versionId = @versionID and propertytypeid = 51 | |
commit tran |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment