Use CASE statement to check if column exists in table – SQL Server

Final answer was a combination of two of the above (I’ve upvoted both to show my appreciation!):

select case 
   when exists (
      SELECT 1 
      FROM Sys.columns c 
      WHERE c.[object_id] = OBJECT_ID('dbo.Tags') 
         AND c.name="ModifiedByUserId"
   ) 
   then 1 
   else 0 
end

Leave a Comment

tech