Skip to content

Instantly share code, notes, and snippets.

@greggnakamura
Last active May 25, 2016 23:58
Show Gist options
  • Save greggnakamura/79c7afd86eeab1ce7a02e09926cd4747 to your computer and use it in GitHub Desktop.
Save greggnakamura/79c7afd86eeab1ce7a02e09926cd4747 to your computer and use it in GitHub Desktop.
SQL: UNION two tables with no relationship, number of columns must match
SELECT [AlertTitle] AS Title
,'' AS Summary
,[AlertBody] AS Description
,[AlertDate] AS Date
,[AlertLink] AS AlertLink
,[AlertType] AS AlertType
,'' AS Location
FROM [Claremont_Kentico8_2].[dbo].[View_claremont_Alert_Joined]
UNION
SELECT [EventName] AS Title
,[EventSummary] AS Summary
,[EventDetails] AS Description
,[EventDate] AS Date
,'' AS AlertLink
,'' AS AlertType
,[EventLocation] AS Location
FROM [Claremont_Kentico8_2].[dbo].[View_CONTENT_Event_Joined]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment