What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 16581 |  Welcome, Guest!   Register  Login
 Home > Forums > Sql Server > How to compare 2 table columns and insert the column name and column value ...
Sundermagar

How to compare 2 table columns and insert the column name and column value in temp table in SQL?

Replies: 2 | Posted by: Sundermagar on 5/5/2010 | Category: Sql Server Forums | Views: 1801 | Status: [Member]  


Hi Friends,

I have a question:

PROBLEM: I have a Table A with 100 columns Table B with 100 columns but column names are not same for Table A and Table B.

I need to compare each column of Table A and Table B and if column value does not matched then insert that particular column name and value to some temporary table.

The comparison should be for each column not for row.

Can any one tell how to do it any technique are welcomed whether using Cursor or Procs.

Thanks
Sunder

Sunder Magar


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Pavanandey
Pavanandey  
Posted on: 5/6/2010 2:14:05 AM
Level: Bronze | Status: [Member]



Let use suppose u have two table A, B with following Colums

A
-----------------
AID , ANAME, AAddress

and

B
-----------------
BID, BNAME, BADddress

now u can open a cursour on table a and compare each row coloum wise and increment a count variable if all the coloums matches else u can leave not increment the count,
one u have done with all the rows then u can check if count is equal to 100 u need not insert else insert in the row in the temp table

Thanks
Pavan Kumar
Mark Answer if this fits the need

Sundermagar, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Nandy
Nandy  
Posted on: 7/4/2010 11:06:20 PM
Level: Starter | Status: [Member]

Please go thru below links
http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=23054

Sundermagar, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 2:11:48 AM