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

How will u get 5 years back record?

5 Answers  


Describe about first three Normal forms.

1 Answers   HP,


What are out-of-range errors with date and time literals?

0 Answers  


Ms sql server index?

0 Answers  


Other than truncate statement, which other command can by-pass the trigger on the tables?

0 Answers  






how can a database be repaired? : Sql server administration

0 Answers  


Define the term DML, DDL and DTL?

1 Answers  


Explain about builtinadministrator?

0 Answers  


What is query optimization process?

0 Answers  


what are the main differences between ms access and sqlserver

1 Answers   C DAC, CDAC,


WHICH INDEX IS FAST CLUSTER AND NON CLUSTER INDEX

4 Answers   CarrizalSoft Technologies, L&T,


how can ur insert the emp table

3 Answers   Wipro,


Categories