Replacing all "http" links within InstantKB articles to "https"



 The following TSQL script can be executed against your InstantKB database to replace all "http" links with "https" links within all your existing InstantKB articles. This can be helpful if your upgrading your web site to http and wish to ensure all images and links embedded within InstantKB articles use https.

NOTE
If your using InstantKB 2018 or above you can perform this find and replace via the global Find & Replace functionality introduced within InstantKB 2018. This is available via the Agent or Admin CP under the Tools menu.

TSQL Find & Replace Script

You will need to execute the below TSQL script against your InstantKB database to replace all references to http with https within your existing InstantKB articles.

DECLARE @find nvarchar(2550)
SET @find = 'http://';


DECLARE @replace nvarchar(2550)
SET @replace = 'https://';


DECLARE @intArticleID int
DECLARE @strArticleText nvarchar(max)
DECLARE MSGCURSOR CURSOR FOR 
SELECT ArticleID, ArticleText 
FROM InstantKB_Articles 

OPEN MSGCURSOR


FETCH NEXT FROM MSGCURSOR
INTO @intArticleID, @strArticleText

WHILE @@FETCH_STATUS = 0
BEGIN


DECLARE @index int
SET @index = CHARINDEX(@find, @strArticleText);


IF (@index > 0)
BEGIN


SET @strArticleText = REPLACE(
@strArticleText, 
@find, 
@replace)


UPDATE InstantKB_Articles SET
ArticleText = @strArticleText 
WHERE ArticleID = @intArticleID


PRINT CAST(@intArticleID AS nvarchar(255))


END

FETCH NEXT FROM MSGCURSOR
INTO @intArticleID, @strArticleText

END
-- tidy cursor
CLOSE MSGCURSOR
DEALLOCATE MSGCURSOR


GO

Once you've executed the above TSQL code against your InstantKB database you should notice all links within articles now use "https" instead of "http". We hope this helps you make the transition to https.