I recently worked on a project where I needed to port data from a MS-SQL database to a mysql database. There are programs, both payware and freeware that will help with this process, but I didn’t have ODBC access to the MS-SQL database, which these programs require. All I had were a bunch of insert statements that looked like this:
INSERT INTO [sample].[dbo].[users_info]([ID],[registration_day],[registration_month],
[online],[gender]) VALUES(463,N'15',N'7',N'2009',N'9:13:52 AM',N'Homer',
CAST(0x9AE90000 AS SmallDateTime),
CAST(0x00009CD700000000 AS DateTime),N'Man');
I wrote a perl script to turn that dialect of SQL into a mysql friendly dialect (feel free to download it).
The most interesting parts were those
CAST statements. This forum post and this blog post helped me turn those casts into real dates. (After loading the inserts into mysql, I did some post processing, using the helpful case statement and str_to_date function to rationalize some of the data.)