SELECT DISTINCT [Table Name].[Column Name], [Table Name 1].[Column Name 2]
SELECT DISTINCT Table_Name.Column_Name, Table_Name_1.Column_Name_2
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$sql = "SELECT DISTINCT [Table Name].[Column Name], [Table Name 1].[Column Name 2]";
echo "{$sql}<br />\n";
preg_match_all('%\[([^\]]+)\]%', $sql, $matches, PREG_SET_ORDER);
$change = array();
foreach ( $matches AS $match ) {
$change[$match[0]] = str_replace(' ', '_', $match[1]);
}
echo str_replace(array_keys($change), $change, $sql);
echo '<hr />';
echo highlight_file(__FILE__);
1