I am Having tables T1 and T2 both having same data how to
check (or) compare the data in both table are same?

Answers were Sorted based on User's Feedback



I am Having tables T1 and T2 both having same data how to check (or) compare the data in both tabl..

Answer / asharaf ali

(SELECT * FROM @T1
EXCEPT
SELECT * FROM @T2)
UNION
(SELECT * FROM @T2
EXCEPT
SELECT * FROM @T1)

If the above query returned no records, the data in both table are same.

Is This Answer Correct ?    7 Yes 1 No

I am Having tables T1 and T2 both having same data how to check (or) compare the data in both tabl..

Answer / saravanan p

Declare @chkSameTable int
Select @chkSameTable=count(*) from
((SELECT * FROM ##SameTable
EXCEPT
SELECT * FROM ##SameTable1)
UNION
(SELECT * FROM ##SameTable1
EXCEPT
SELECT * FROM ##SameTable)) DrvTable

If @chkSameTable=0
Print N'The Two Tables are having Same data'
Else
Print N'The Two Tables are having Diferent data'

Is This Answer Correct ?    1 Yes 0 No

I am Having tables T1 and T2 both having same data how to check (or) compare the data in both tabl..

Answer / thakur singh rawat

(select * from T1
minus
select * from T2)
union
(select * from T2
minus
select * from T1)

If no rows returns then it means that the two tables
contain the same values or say same.

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More SQL Server Interview Questions

Explain powershell included in sql server 2008?

0 Answers  


Stored Procedure returns data from multiple tables. How to access it in your ASP.Net code?

0 Answers   HCL,


How to how to convert numeric expression data types using the convert() function??

0 Answers  


How do I port a number to sql server?

0 Answers  


how to select 5 to 7 rows from a table, which contains 10 rows?

21 Answers   IBM,






What is an index in a database?

0 Answers  


What about UPDATESTATISTICS ?

2 Answers   HCL, Intelligroup,


Explain transaction server implicit?

0 Answers  


How to turn on the mssql api module in php?

0 Answers  


What is indexing explain it with an example?

0 Answers  


What is merge replication?

0 Answers  


Explain view in sql server?

0 Answers  


Categories