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

Top 5 Contributors of the Month
Post New Web Links

compare two column from different tables

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

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 ?

View Complete Post

More Related Resource Links

Select column from all tables in database

I want to retrieve the name and phone columns from all the tables in my database not in systables....   Ok this works but i dont want to get it from just the test table I want to get it from all the tables that I create "USE mrpoteat SELECT name, phone FROM mrpoteat.dbo.test where name = name and phone = phone"

Rename a column in multiple Tables using sp_rename

Hi,Any work around for the below issue?Originally "LoadDate" column (see below scripts) was there both in tables DIM_Table_1 and DIM_Table_2According to change in requirement, LoadDate in both the tables to be chnged to LOAD_DATE. It has to be done through script-----------------EXEC sp_rename 'dbo.DIM_Table_1.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Successfully executedEXEC sp_rename 'dbo.DIM_Table_2.LoadDate',     'LOAD_DATE', 'COLUMN'         -- Error: See below Error: The new name 'LOAD_DATE' is already in use as a COLUMN name and would cause a duplicate that is not permitted.-----------------

Discovering ODBC Tables, Columns and column Definitions

I have worked with ODBC data connections for a while.  Usually, I've setup a connection to some type of database (IBM ISeries, SQL Server, Progress, etc.) depending on the project and then I use MS Access to inspect or export the data using linked tables. I have a database that has numerous tables and columns.  In fact, I believe there are some 16k data columns in the entire database.  Furthermore, I have an excel file that gives me a list of all of these tables and a brief description of each column  but it does not have useful data types in the description.  What I would like to do is query the ODBC source and extract each table, it's columns and it's column data types. My end goal is to take the data from the spread sheet (column names and description) and insert that data into a database that also contains the correct, SQL data type in an additional field.  Is there a way to query an ODBC data source to acquire all of this information?

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

Find all tables that depend on table with FK column

I need to write a stored procedure that when passed the id of a row on a table, will query all tables that are referencing that row and move the data to another row.  I am doing this because we have 2 seperate systems that are linked by a table and sometimes things get out of whack and you have to manually move information over. I have this query that can find all the dependent tables, my question is what would I add to this to obtain the name of the column that is the foreign key on that tables.  SELECT o.name[parentTable], o2.name[childTable] FROM sys.sysobjects o INNER JOIN sys.sysforeignkeys fk ON fk.rkeyid = o.id INNER JOIN sys.sysobjects o2 ON o2.id = fk.fkeyid AND o2.id <> o.id WHERE o.name = 'tablename' I want to do this as a query because I want the procedure to be able to detect any new tables that might have been added.

Caculated column formula for user name Compare

Hi , i  have a formula in sharepoint 2010 (form library->validation setting-> formula $ userdefine message)  example : =username =<"2" user messge  your request is already existing ,,, i have  1fields that user name but i need formula for is user already existing two time we did not allow  3 time i am using of validation setting and formula in sp2010 Regards Raju

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

How to Compare Text Column with Today Calculation in view?


I  have 2 columns

Birth Date (DateTime), Birth-Month(Text- Calculated from Birth Date with MONTH([Birth Date]))

Now I want to know who's birthday in this running month?

So How can I implement filter or CAML Query for a view.


Regards, Kashyap Patel http://interview-question-aspnet.blogspot.com/

SQL - Join Tables on Column Name and Row Field Value



I have two SQL tables (SQL 2005) that I need to join but am in need of some assistance. Essentially I need to join a column name with row field values.

The first table contains the following columns

  • Loan ID
  • SSN
  • Ord_SignedApp
  • Ord_Title
  • Ord_Reg
  • Ord_Name

The second table contains the following columns

  • Item
  • Ord

However, the rows in the second table for the Ord column contain the following values:

  • Ord_SignedApp
  • Ord_Title
  • Ord_Reg
  • Ord_Name

I need to join the row field value of the second table with the column name of the first table. I want to display the values of the respsective columns of table one (Ord_SignedApp, Ord_Title, Ord_Reg, Ord_Name) and place them in a new column. These values are represented as dates

Any assistance you can provide would be much appreciated.

Thank you for your help,




need to join two tables and also convert top 3 rows to column


Hi, I have two tables, CUSTOMER and PAYMENT_DETAILS. I need to extract "name" and "phone" from CUSTOMER table and TOP 2 payments for matching email from PAYMENT_DETAILS table. Kindly refer to the attached image for table structure and Result required.




Compare data in a single column overtime



I have the below sample table and is trying to compare the data accross time in the Account field. Basically if the Account field changed from NULL (default) it can not go back to NULL or change to another type. My goal is to list where the field value changed from Accept back to NULL or Reject back to NULL or Accept to Reject or Reject to Accept. NULL is the default value.



TABLE [dbo].[T2](

[ID] [smallint]


Tables column relationship

In AdventureWorks sample. considering Fact "Internet Sales" and "Date" dimension, now there are 3 columns in "Internet Sales" Fact table ShipDateKey,OrderDateKey and DueDateKey which are mapped to DateKey column of Date dimension.
My question is if i drag and drop any measure from Internet Sales and use Date dimension on rows then how SSAS answers query result and which fact and dimension column relationship it use. i.e. which column amongst 3 i.e. ShipDateKey,OrderDateKey and DueDateKey it will use for response.

compare tow tables contents


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

Union all in SSIS join two tables row wise or column wise

Union all in SSIS join two tables row wise or column wise

Insert NULL values into Integer column in Access 2007 tables

hi  there:

  My source data  is below and it's in CSV format

Days waited


My destination is a Number column in a 2007 access table  and the required property is set to NO

First question :

   I used a Data conversion task in DFT to convert [DT_STR] to Integer as SSIS seems to default the source as DT_STR type. However, SSIS keeps complaining that

"The conversion returned status value 2 and status text "The value could not be converted because of a potential loss of data."

I know that's because of those NULL values. how to solve this issue?


--Currently using Reporting Service 2000; Visual Studio .NET 2003; Visual Source Safe SSIS 2008 SSAS 2008, SVN --

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.

rowGuid column MUST be unique on all the tables for a same database or not ?



I've got a lot of troubles for the moment with Merge replication about data not downloaded.

But, i've got an idea. Maybe the problem is about rowguid.
I explained : after the publication is created, I saw new columns added in the tables : name rowguid,type Guid, property rowGuid.

To avoid uses a GUID value on the database for all tables publiched, for all rows, and because my Primary key on all tables is always a guid, I've added the property "rowguid" to my primary key.

BUT, my PrimaryKey is unique on the table, but not on the whole database means not on all the tables.

My question : is it a problem ? does the value of one "rowguid" must be unique on all tables of the database, or, 2 rowguid can have the same value if they are on the same publication but from 2 different tables ?



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