In what scenarios should square brackets be used around column names in SQL queries when working with MSSQL through PDO in PHP?

Square brackets should be used around column names in SQL queries when working with MSSQL through PDO in PHP if the column name contains special characters, spaces, or is a reserved keyword. This ensures that the query is properly interpreted by MSSQL.

// Example SQL query using square brackets around column names
$stmt = $pdo->prepare("SELECT [column name], [another column] FROM table_name WHERE [condition] = :value");
$stmt->bindParam(':value', $value);
$stmt->execute();