Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Compare data between two tables of same schema

$
0
0

Folks,

I have one very intresting query which i would like to share with you all and looking forward for the solution asap.

Scenario

I have two table say TableA and TableB, both having same structre say as below

TableA

Col1 Var(10)

Col2  INT

TableB

Col1 Var(10)

Col2  INT

I want to compare data between these two tables and store compared data into third table, let me expalin the whole scenario.

TableA

ColA          ColB

INDIA          1

PAKistan      2

               

TableB

ColA          ColB

INDIA          1

PAK             3

I want result like

Difference

ColA          ColB

True            0

False           -1

I want to store this difference in thrid table.

i.e. when comparing text, i need TRUE when compare 100% else False, Caption is not considered.

     When comparing numeric value, simple sub is requried , TableA-TableB

Note - I dont want to use any external tool to compare the table data, i required sql query to do the same.

Thanks

Amit Srivastava


Amit
Please mark as answer if helpful
http://fascinatingsql.wordpress.com/



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>