SQL Server 2005 2008 Integration Services (SSIS) information, products, free scripts, tasks, components, productivity
Got a SQL Server or .NET question? Discuss it in the forums. (SQL Server Forums | Dot NET Forums)
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.

Joining Results of two Datasets Avoiding Dulicates

rated by 0 users
Not Answered This post has 0 verified answers | 4 Replies | 2 Followers

Top 200 Contributor
6 Posts
Points 165
poncho posted on 01-28-2010 8:11 AM

I want to join the results given by two queries and avoid duplicates in this is there any way to do so.

  • Filed under:
  • | Post Points: 20

All Replies

Top 10 Contributor
Male
116 Posts
Points 1,335
You can use UNION to join results of two datasets. Hope this will help
  • | Post Points: 20
Top 200 Contributor
6 Posts
Points 165

Hi Ashish

Thanks for help but i am getting this error not sure what is this as i am a newbie to SQL. here is the error...

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

  • | Post Points: 35
Top 500 Contributor
5 Posts
Points 60

the error suggests that you need to have same number of columns on all the queries separated by UNION. Also datatypes of corresponding columns in queries should be same (i.e if 3rd column in first query is int then 3rd column in other queries should also be int or some value which can be casted to int.

  • | Post Points: 5
Top 10 Contributor
Male
186 Posts
Points 2,805

poncho:

Hi Ashish

Thanks for help but i am getting this error not sure what is this as i am a newbie to SQL. here is the error...

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

 

Post the code you used

  • | Post Points: 5
Page 1 of 1 (5 items) | RSS

Copyright © Beyondrelational.com