Hi,
I have this query
CREATE TABLE #Summary(SourceQueryRowCount INT, TargetQueryRowCount INT, QueryDiffRowCount INT)
CREATE TABLE #CompareResult(DataSource varchar(50), ID int, Rule1 varchar(50), Rule2 varchar(50))
;WITH SourceQuery AS
(
SELECT * FROM (VALUES( 1, 'a','b'),(2, 'c','d'),(3,'e','f'))rs(id,rule1,rule2)
WHERE rs.rule1 != 'a'
),
TargetQuery AS
(
SELECT * FROM (VALUES( 1, 'a','b'),(2, 'c','d'),(3,'e','f'))rs(id,rule1,rule2)
)
INSERT INTO #CompareResult
SELECT DataSource = 'SourceToTarget', * FROM SourceQuery EXCEPT SELECT DataSource = 'SourceToTarget', * FROM TargetQuery
UNION ALL
SELECT DataSource = 'TargetToSource', * FROM TargetQuery EXCEPT SELECT DataSource = 'TargetToSource', * FROM SourceQuery
and I want to get rows count in variable or #Summary table and compare result set into table #CompareResult.
I did this with create seprate temp table for SourceQuery and TargetQuery and then compare it but as source and target queries result set are huge and i want to perform every thing in one set. is this possible.
Thanks