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

Top 5 Contributors of the Month
Post New Web Links

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

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :Sql Server
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

View Complete Post

More Related Resource Links

Select "Name" from all Tables in SQL Server

I am trying to Select column "Name" from all the Tables in SQL Server     Dim MyConnection2 As New SqlClient.SqlConnection("Data Source=XXX")            Dim mydtadapter2 = New SqlDataAdapter("Select o.name + '.' + c.name from syscolumns c, sysobjects o where (c.name & 128 = 128) and o.name = c.name order by o.name", MyConnection2)            Dim ds As New DataSet            mydtadapter2.Fill(ds, "name")                                  clientname2.DataSource = ds.Tables("name").DefaultView            clientname2.DataBind()

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"

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

Need help with SELECT statement for multiple tables


Here's my current SELECT statement:

SELECT u.Email FROM UserProfiles p, aspnet_Membership u WHERE p.RulesCheckBox = 'True' AND u.UserId = p.UserId

This gives me a list of registered member email addresses that have selected the RulesCheckBox in their profile, so I can email them with an email script.  There is a relationship between the Membership table and the UserProfile table, so it finds the email addresses from the Membership table where that user has the RulesCheckBox checked in their profile (in UserProfiles table).  I'm wanting to add some additional names to this list, from a different table. The purpose is so I can manually add email addresses to the additional table, so the additional email addresses will also receive the same email, even though they aren't registered members of the site.

So how can I adjust that SELECT statement so this one is combined with it somehow?:

SELECT Email FROM ExtraEmails WHERE Rules = 'true'

INSERT the Results of a Stored Procedure with Multiple SELECT Statements into Multiple Tables?

I have a stored procedure (which is overly complex and written by someone else) that I need to take the results of and put them into tables.  The stored procedure uses Dynamic SQL to build and then run 5 SELECT statements based on literally hundreds of variables.  I need to take the results of these SELECT statements and put them into tables in a different database.  Rewriting or re-creating the logic of the stored procedure is NOT AN OPTION as the logic may change over time and maintaining it in multiple places would be nightmarish.  Can anybody help me with this?  I've googled extensively, but have only been able to find examples of using one result set not multiple ones.

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

Stored Procedure to Retrieve Zipcodes within a specified Zipcode and distance


Hi All,

Does anyone have a Stored Procedure that works perfectly to retrieve all zipcodes within a specified zipcode and distance radius - a zipcode and radius is passed and the Store Procedure result shows all zipcodes that falls within that range.


Thanks in advance



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 ?

Using Data Tables.Select

I am missing something in trying to select a record  from a data table.  
The commented out code works fine but when I modify it to try and use Select. the bold lines, I get an erroron the last line,
"Nutr_Val" is throwing this - Cannot implicitly convert 'string to 'int'.  
Thanks for any help.
strNDB_No = Convert.ToString(cRow["NDB_No"]);
//string strNutr_No = "203";
DataSet dsUSDANUT_DATA = new DataSet();
//string strSql1 = "select * from NUT_DATA WHERE NDB_No = " + "'" + strNDB_No  + "'" + " AND Nutr_No = " + "'" + strNutr_No + "'";
string strSql1 = "select NDB_No, Nutr_No, Nutr_Val from NUT_DATA WHERE NDB_No = " + "'" + strNDB_No + "'";
OleDbDataAdapter daUSDANUT_DATA = new OleDbDataAdapter(strSql1, cn1);

                if (dsUSDANUT_DATA.Tables[0].Rows.Count > 0)
                    //DataRow xRow = dsUSDANUT_DATA.Tables["USDANUT_DATA&q

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


Dataset.tables.Select method


I want to select student who belogs to New York.so this purpose i write query as

ds.Tables("student").select("city==NewYork"); it is not work


"ds" is dataset

"city" is column name

"New York" is the string

Can anybody help me? 

Give me suggestion 

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

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..

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