Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
goligol
Posting Yak Master
128 Posts |
Posted - 2011-12-05 : 17:06:53
|
| I have a table that most of the rows are duplicated:hts_code naics8_02 ust_code district port port_district fips0101100010 11292000 3330 52 06 5206 120250101100010 11292000 3330 52 06 5206 120250101100010 11292000 4120 52 06 5206 120250101100010 11292000 4120 52 06 5206 120250101100010 11292000 4231 52 06 5206 120250101100010 11292000 4231 52 06 5206 12025How I can only keep one?thx |
|
|
consultor.dwh
Starting Member
6 Posts |
Posted - 2011-12-05 : 17:21:28
|
| select distinct *from table |
 |
|
|
mmarovic
Aged Yak Warrior
518 Posts |
Posted - 2011-12-05 : 18:55:53
|
| [code]select distinct *into new_tablefrom existing_table;exec sp_rename 'existing_table' 'temp_name' --just in caseexec sp_rename 'new_table' existing_tablego[/code]if everything goes well you can dropt table temp_nameMirkoMy blog: http://mirko-marovic-eng.blogspot.com/ |
 |
|
|
|
|
|