I am receiving a:
Conversion failed when converting from a character string to uniqueidentifier
error when I attempt to UNION ALL
two identical queries that have been wrapped in subqueries. I am not sure what this is referring to since the queries work fine individually. Could it be the syntax?
SELECT *
FROM (
SELECT
Table1.[Owner]
FROM
(
SELECT
owneridname [Owner],
incidentid [Ticket Number1]
FROM
incident
) as Table1
LEFT JOIN
(
SELECT
MAX(DATEADD(hh,-7,svb_timestamp)) [Time Stamp],
svb_caseid [Ticket Number2]
FROM
svb_caseupdate
GROUP BY svb_caseid
) as Table2
ON Table1.[Ticket Number1] = Table2.[Ticket Number2]
) sq1
UNION ALL
SELECT *
FROM (
SELECT
Table1.[Owner]
FROM
(
SELECT
svb_cssowner [Owner],
incidentid [Ticket Number1]
FROM
incident
) as Table1
LEFT JOIN
(
SELECT
MAX(DATEADD(hh,-7,svb_timestamp)) [Time Stamp],
svb_caseid [Ticket Number2]
FROM
svb_caseupdate
GROUP BY svb_caseid
) as Table2
ON Table1.[Ticket Number1] = Table2.[Ticket Number2]
) sq2
I was expecting to append both tables together which should be fairly simple.
threeballedalien is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.