Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
i want to find out unique data from huge amount of data like 500000 records in sql 2008.

What I have tried:

DELETE
FROM dbo.w3
WHERE dbo.w3.%%physloc%%
NOT IN (SELECT MIN(b.%%physloc%%)
FROM dbo.w3 b
GROUP BY b.CHASSIS_NO);

SELECT distinct TOP 500000
[CHASSIS_NO]
FROM [TestDB].[dbo].[w3]
Posted
Updated 29-Jun-17 20:45pm
v2
Comments
Richard MacCutchan 29-Jun-17 5:36am    
What is the question?
Member 13284521 29-Jun-17 8:09am    
the question is ,if i have huge amount of data than which query is giving right ans and i want to store that data into another table...i tried but table is not created.
Richard MacCutchan 29-Jun-17 8:22am    
SELECT returns a set of records so you now need to INSERT them into the other table. See https://www.w3schools.com/sql/sql_select_into.asp.
Member 13284521 29-Jun-17 8:29am    
SELECT TOP 500000 [Slno]
,[REGION]
,[CODE]
,[DLRNAME]
,[SALU]
,[NAME]
,[ADDRESS1]
,[ADDRESS2]
,[ADDRESS3]
,[CITY]
,[PIN]
,[MOBILE_NUM]
,[CHASSIS_NO]
,[REGIST]
,[ENGINE]
,[MODEL]
,[MODEL CODE]
,[KILOMETER]
,[TYPE]
,[SERVICE_DT]
,[BILLING_DT]
,[Month ]
,[Year]
,[Quarter 12-13]
,[Quarter 13-14]
,[Quarter 14-15]
,[Quarter 15-16] into #temp
FROM [TestDB].[dbo].[w2] order by [Slno]

is this right query???
Richard MacCutchan 29-Jun-17 9:02am    
No idea. Why don't you try it with a small number of records to find out?

1 solution

To store the data in a new table:
SQL
SELECT distinct TOP 500000 [CHASSIS_NO] 
INTO newtable
FROM [TestDB].[dbo].[w3]
 
Share this answer
 
Comments
Member 13284521 30-Jun-17 1:14am    
little more help sir..when i convert excel data into sql ,my data became random means slno not in mannner .so what can i do now?
RickZeeland 30-Jun-17 4:22am    
Restore from a backup ?
Member 13284521 30-Jun-17 4:33am    
nope. actual data in excel format and i want to convert into sql without changing.
RickZeeland 30-Jun-17 5:34am    
Maybe you can use this, don't know if it works for SQL Server Express: https://www.mssqltips.com/sqlservertutorial/203/simple-way-to-import-data-into-sql-server/
Member 13284521 30-Jun-17 6:15am    
i already use this method.but still problem in converted data.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900