Skip to content

Instantly share code, notes, and snippets.

View markryd's full-sized avatar

Mark Rydstrom markryd

  • Brisbane, Australia
View GitHub Profile
if not exists (select column_name from INFORMATION_SCHEMA.columns where TABLE_SCHEMA = 'dbo' and table_name = 'Deployment' and column_name = 'ChannelId')
BEGIN
ALTER TABLE dbo.Deployment ADD ChannelId nvarchar(50) NULL
END
GO
-- Update column from json blob. Try to extract rather than joining on Release since it may have changed.
UPDATE dbo.Deployment
SET ChannelId = c.Id
FROM dbo.Deployment d INNER JOIN dbo.Channel c ON d.[JSON] LIKE '%"ChannelID":"' + c.Id + '"%'