.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

compare tow tables contents

Posted By:      Posted Date: October 18, 2010    Points: 0   Category :Sql Server

Hi guyz

I`vo got to tables wich are equal to each other in their structure


	[Mat_ID] [bigint] NOT NULL,
	[Mat_Arb_Name] [varchar](300) NOT NULL,
	[Mat_Lat_Name] [varchar](300) NULL,
	[Mat_Parent_ID] [bigint] NOT NULL,
	[Mat_Type] [tinyint] NOT NULL,
	[Mat_Notation] [varchar](255) NULL,
	[Mat_Current_Quantity] [float] NULL,
	[Mat_Unlinked_Unit_Qty] [float] NULL,
	[Activation] [bit] NULL,
	[Created_ID] [smallint] NULL,
	[Updated_ID] [smallint] NULL,
	[Updated_Date] [datetime] NULL,
	[Created_Date] [datetime] NULL,
	[Work_Type] [int] NULL,


but each of them is on a different database on the same server.

what I want to do is comparing the contents of them and specif

View Complete Post

More Related Resource Links

compare data from tow tables ?

HI all I have tow tables ,, i want to add Column1 from table1 to Column1 in table2 , where Column2 in table1 is bigger than Column2 in table2

I want to compare zipcodes from all the 4 tables and have to select the zipcode which has a value

Hi , I want to select zipcode from 4 different tables based on a condition using SQL select Query. I have to find which table is satifying the condition and returning a zipcode and use that particular zipcode for my further processing. (Only one table will satisfy the condition, i want to find which table is that and i want to get zipcode from that particular table.) Could anyone Please advice me? Thank You

compare two column from different tables


i have records in a column called CLI such that "10-7;10-8;10-9;10-10" and in another table records such that "10-7","10-8","3-2",column X.

how i can find the records that found in CLI but not found in X column.

For example,record "10-7;10-8;10-9;10-10" in CLI

is there 10-7 in column X ?

is there 10-8 in X ?

is there 10-9 in X ?

is there 10-10 in X ?

Compare two tables in MSSQL database

I shall compare two large tables in a MSSQL database. tables have about 10 fields each. and my problem is that there is a lot of "IF" in the task description .. ie IF field 1 in table 1 does not exist, then it is compared with felt2 and felt3 in tabel2 .. etc.. have many IF.

How can this be easily resolved ..?

I know that "IF" can be solved by setting up CASE in sql, but can only be solved using. SQL, or should any programming to also ..?

thanks in advance.

compare two columns in two data tables



is there an easy way to compare two columns in two datatable to see if they match?

I need to check if the values in column["x"] of datatable1 occur in column ["y"] of datatable2, without iterating through both tables (for each value in column of dt1, check column of dt2).

I tried:

foreach (DataRow dr in dt1.rows)

if (dt2.rows.find(dr["x"])

but this checks the whole row and if finds an "x" in any column, "if" condition is true. I need to only check one column of dt2.

Tables have different columns but the same primary column and that's what I need to check


MS SQL Server: Search All Tables, Columns & Rows For Data or Keyword Query

If you need to search your entire database for specific data, this query will come in handy.

So when a client needs a custom report or some sort of custom development using Great Plains, most of the time I will have to track down the data in the system by running this query and find the table(s) it is in.

Temporary Tables - MS SQL Server

Usage of temporary tables in MS SQL Server is more developer friendly and they are widely used in development. Local temporary tables are visible only in current session while global temporary tables are visible across all sessions.

Temporary tables in SQL Server vs. table variables

When writing T-SQL code, you often need a table in which to store data temporarily when it comes time to execute that code. You have four table options: normal tables, local temporary tables, global temporary tables and table variables. I'll discuss the differences between using temporary tables in SQL Server versus table variables.

Compare List


i have got two list<string> containing datas

i would like to compare the both list and the result to new list whch does not contains the same data.(basically unique data)

eg shown below..

list A       list b          list c

a             a                 d

b           d                    c

c            f                   e

f            e

plz let me knw..

Using a trigger or anything else to populate two tables


Hi! I'm creating an application that's supposed to first add a record to table1, and then get the ID from that record to use when adding a record to table2, to be able to associate these two records with eachother.

The user gets to type in some values that goes to table1, and some values that goes to table2, but before the insert statement for table2 is executed i need the ID from the recently added record in table1. Some dude told me to use a trigger for the autopopulate purpose, but does that really work when i also need to save some values that's user input, and when those values doesn't get saved in table1?

Are there any other way to do this or can i send values to a trigger? I'm new to triggers and stored procedures, i don't have any particular knowledge of this, any help is appreciated!


Regards, Monsterbadboll

merging multiple tables in a single dataset to single table


 i have a stored procedure which returns three tables to a dataset ..... now i need to merge all three tables to a single table from d same dataset 

like dataset1 has table1 table2 and table3 .... i want all the three tabels to be merged into dataset1 itself .... instead of three diffrent tables so that i can show all three table data in a single datagrid  as a compact data and combination of 3 tables from d single dataset.....

can some1 help me please.....

SqlDataSource UpdateCommand using 2 tables


I have two tables

Trans  with fields TransID, Date, CustomerID and some other stuff

Customer with fields CustomerID, Name, TaxId

On the screen the user only sees the fields Date and Customer Name. CustomerID is behind the scenes only.


I'm using SqlDataSource. Having no problems with SelectCommand. I don't know how to construct the UpdateCommand and InsertCommand.

Let's say the user changes the date, then I need to do an UPDATE.

UPDATE Trans SET Date = @Date, CustomerID = @CustomerID results in an error message and the record is not updated.

I get an error on the page that says "Sys.WebForms.PageRequestManagerServerErrorException: Input string was not in correct format".


I tried taking out the set for CustomerID and I still get the error on page.


Also, for inserting, the users will see a dropdownlist with Customer Names. I need to convert that to a CustomerID to be used in the new record being inserted in the database. I'm not sure how to do this.


Do I need to do something with Control Parameters?

How to display related tables in one crystal report and how to link this report with combobox?


Hi! I want to display a crystal report in my vb.net application. Suppose I have tables named student details, student marks, student address, etc... Now if I want to display all these details (fields of all tables) in one crystal report (with page breaks if necessary) then how will I achieve it. I will be providing a combo box in my application that contains list of student names. How can I link this combo box with the cystal report to dynamically display report for different student on selected index change of combo box? Help me friends. An example would be appreciable.

Data Points: Creating Audit Tables, Invoking COM Objects, and More


Dealing with error handling between T-SQL and a calling application, evaluating when a field's value has changed, and creating auditing tables in SQL ServerT are all common issues that developers must tackle.

John Papa

MSDN Magazine April 2004

Sql Scripts - Delete all Tables, Procedures, Views and Functions


In a shared environment you typically don't have access to delete your database, and recreate it for fresh installs of your product. 

I managed to find these scripts which should help you clean out your database.

Use at your own risk.


Delete All Tables

--Delete All Keys


filter n compare between two table in resultset


Hi .. I have two table 

Say Table1 n Table2


Item              ItemName

001                 Laptop

001                  PC

002                  PC

002                  Printer

003                  Pendrive

004                  Keyboard

004                  CPU


Item                  ItemName

001                   laptop

001                   PC

002                   Printer

004                   CPU

Here am comparing table1 with table2

The Itemname which is available in both table1 n table2 should be dropout ... Other Item should be displayed ...

I need the sql result set like this :

Item                 &n

Join Two Tables and Prepare Report



            I have a select query which is executing well. Now, I want to add one more field to that query. That field is not in the current query table, It is in the another table.

How do I join those two tables and get that field value in the existing select query.?


ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend