how to elimainte the similar data from the different tables



how to elimainte the similar data from the different tables ..

Answer / Rahul Sagar

In ASP.NET, you can eliminate or prevent duplicate data across multiple tables by implementing unique constraints or primary keys at the database level and using SQL INNER JOINs with WHERE clauses to retrieve non-duplicate records. Here's an example of how to do that:

```csharpnstring connectionString = ConfigurationManager.ConnectionStrings["MyDb"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();

string query = "SELECT a.*, b.* FROM TableA AS a INNER JOIN TableB AS b ON a.Id = b.Id WHERE a.Id NOT IN (SELECT Id FROM TableC)";

using (SqlCommand cmd = new SqlCommand(query, conn))
{
using (SqlDataReader reader = cmd.ExecuteReader())
{
// Process the result set here
}
}
}```nThis example uses a SQL INNER JOIN to fetch data from TableA and TableB where Id is unique in both tables, but not present in TableC.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

Is post back property in asp net?

1 Answers  


What are the ways of preserving data on a Web Form in ASP.NET?

1 Answers  


what are the new server controls added in Asp.net 2.0?

1 Answers   DOSPL,


What is the default authentication mode for asp.net?

1 Answers  


How can we update records in gridview?Is there any appropriate code for it?

1 Answers  


What is use of <% %> in asp.net?

1 Answers  


What is the difference of a LEFT JOIN and an INNER JOIN statement? What is a Cartesian product? What causes it?

1 Answers   Syntax Softtech,


To call a Web service which transport protocol you can use?

3 Answers   Siebel,


Explain the use of view state?

1 Answers  


Which method do you use to enforce garbage collection in .net?

1 Answers  


What are the new data controls in asp.net 2.0?

1 Answers  


How do you turn off cookies for one page in your site?

2 Answers   IBS,


Categories