Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS SQL to MYSQL

Status
Not open for further replies.

conceptmgt

IS-IT--Management
Sep 12, 2001
45
GB
Hi

I had a system that works fine in MS SQL 7 and I am converting it to MYSQL. I had a script that removes duplicates below:

strsql = "DELETE FROM EmailAddresses WHERE"
strsql = strsql + " EXISTS ("
strsql = strsql + " SELECT"
strsql = strsql + " NULL"
strsql = strsql + " FROM"
strsql = strsql + " EmailAddresses b"
strsql = strsql + " WHERE"
strsql = strsql + " b.[EmailAddress] = EmailAddresses.[EmailAddress]"
strsql = strsql + " GROUP BY"
strsql = strsql + " b.[EmailAddress]"
strsql = strsql + " HAVING"
strsql = strsql + &quot; EmailAddresses.[EmailAddressid] < MAX(b.[EmailAddressid])&quot;
strsql = strsql + &quot; )&quot;

It won't work on the MYSQL database any ideas?

Thanks

Gary
 
You need to do it in multiple steps

create temporary table t(emailaddresses varchar(100))
insert into t select distinct EmailAddress from EmailAddresses
delete from EmailAddresses
insert into EmailAddresses select * from t
drop table t

Going from mssql to Mysql will requeire a lot of rewrite due to the lack of standard sql features in Mysql. If you are looking for a free dbms there are others that will be eaasier to port to, e.g. postgres, firebird and SAP.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top