Need help with a script(SQL server)
Need help with a script(SQL server)
(OP)
I need help with a scripts
I want to creat an SQL scripts that go thru a table and
delete all the multiple entries and only keep one entry.
Table Addressbook
ID FirstName LastName City State Zip
thanks
Mo
I want to creat an SQL scripts that go thru a table and
delete all the multiple entries and only keep one entry.
Table Addressbook
ID FirstName LastName City State Zip
thanks
Mo
RE: Need help with a script(SQL server)
Addressbook_temp
run a script thus:
insert into Addressbook_temp
select ID,FirstName,LastName,City,State,Zip from addressbook
group by ID,FirstName,LastName,City,State,Zip
delete the old table addressbook and then rename Addressbook_temp to Addressbook
Best method would be not to allow duplicates, via using a replace statement to insert data into your database. But that depends on the database you are using.
Technological progress is like an axe in the hands of a pathological criminal
RE: Need help with a script(SQL server)
Do not forget to assign a UNIQUE clause to the table for FirstName or FirstName and LastName or whatever field(s) you think it will be necessary, to avoid future record duplication.