By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,938 Members | 1,967 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,938 IT Pros & Developers. It's quick & easy.

Removing duplicate records and to store in new table with single query

P: 64
Hi

I am having table with more 13 lakhs records.

I am having duplicate records in it.

i need to remove that.

I wrote the following query
SELECT *
FROM chitta union SELECT *
FROM chitta;

its working fine and showing records after removing duplicate records

but the following query giving error
SELECT * into Table2
FROM Table1 union SELECT *
FROM Table1;
Sep 24 '07 #1
Share this Question
Share on Google+
1 Reply


azimmer
Expert 100+
P: 200
Hi

I am having table with more 13 lakhs records.

I am having duplicate records in it.

i need to remove that.

I wrote the following query
SELECT *
FROM chitta union SELECT *
FROM chitta;

its working fine and showing records after removing duplicate records

but the following query giving error
SELECT * into Table2
FROM Table1 union SELECT *
FROM Table1;
Your first SELECT ... UNION doesn't make much sense: it just returns the same lines as SELECT * FROM chitta (since it is the same set as with the UNION).
If you need to remove duplicates use the DISTINCT keyword with SELECT:
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT * FROM chitta
  2.  
or
Expand|Select|Wrap|Line Numbers
  1. SELECT DISTINCT * INTO Table2 FROM chitta
  2.  
Sep 24 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.