Showing posts with label SQL 2008. Show all posts
Showing posts with label SQL 2008. Show all posts

Tuesday, April 9, 2013

Convert MSSQL to MYSQL

For the sake of speed I developed a lot of ETL procedures in MSSQL 2008 and now have to convert them to MYSQL.

Some notes writing TSQL so that conversion is as painless as possible:
  • table aliasses are case sensitive
  • comments ("--") only work if there is a space after the dashes
  • Use Cast() instead of Convert(). MYSQL does have a Convert function, but the syntax is different. Also, the names of the data types you can convert to are different
When converting your code:
  • Datepart() does not work so change to Date_Format() instead. link
  • Dateadd() does not work so change to Date_Add() or Interval instead. link
  • All statements should be ended with a ";"
  • DateDiff is available in MYSQL but has different parameters. link
  • Cast() works in MYSQL but the type names differ. link
Be sure to run a find replace on the following:
  • "dbo." replaced with "MYSQLSchemaName."
  • ISNULL replaced with IFNULL
  • "[" replaced with "`" 
  • and "]" replaced with "`"