Skip to content

Instantly share code, notes, and snippets.

@vanessalove
Created July 13, 2016 23:13
Show Gist options
  • Save vanessalove/ad2c6b4d4a450d53048b5557189e79bb to your computer and use it in GitHub Desktop.
Save vanessalove/ad2c6b4d4a450d53048b5557189e79bb to your computer and use it in GitHub Desktop.
select * from dbo.Deployment d LEFT JOIN dbo.Channel c
ON d.[JSON] LIKE '%"ChannelID":"' + c.Id + '"%'
WHERE c.Id is null
select * from dbo.Deployment d LEFT JOIN dbo.Release r ON d.ReleaseId = r.Id
WHERE r.ChannelId IS NULL
select * from dbo.Deployment d cross apply (
select top 1 c.Id as ChannelId from project p inner join channel c on p.Id = c.projectId
where p.Id = d.ProjectId
order by
p.Id,
case when c.json like '%IsDefault":true%' then 0 else 1 end) as x
WHERE x.ChannelId IS NULL
select * from dbo.Deployment d cross apply (
select top 1 c.Id as ChannelId from channel c
order by
case when c.json like '%IsDefault":true%' then 0 else 1 end,
c.Id) as x
WHERE x.ChannelId IS NULL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment