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

What is onf in normalization form?

1 Answers  


How to count rows with the count(*) function in ms sql server?

1 Answers  


Which databases are part of SQL server default installation? Explain the usage of each?

2 Answers   Accenture,


Explain system rowset functions?

1 Answers  


How to download and install microsoft sql server management studio express?

1 Answers  


What is sql server locking?

1 Answers  


What are recommended options to be used while using db mirroring? : sql server database administration

1 Answers  


How do we get current date in SQL Server 2000, Oracle, MS Access?

13 Answers  


How to create a ddl trigger using "create trigger" statements?

1 Answers  


How can we get count of the number of records in a table?

1 Answers  


how to get the salary in descending order with out using the keyword desc in sql

5 Answers   Ramco,


What are different types of schemas?

1 Answers  


Categories