Skip to content

Instantly share code, notes, and snippets.

@treffynnon
Created February 4, 2010 15:19
Show Gist options
  • Save treffynnon/294727 to your computer and use it in GitHub Desktop.
Save treffynnon/294727 to your computer and use it in GitHub Desktop.
Convert MySQL tables to T-SQL
<?php
$conn = mysql_connect('host','user','pass');
mysql_select_db('database',$conn);
$SQL = "SHOW TABLES;";
$result = mysql_query($SQL, $conn);
while($row = mysql_fetch_array($result))
print "SELECT * INTO SQLServerDBName.dbo.{$row[0]}<br />
FROM openquery(MySQL, 'SELECT * FROM `{$row[0]}`');<br />
";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment