To get your SQL Azure DB running with Symony 1.4 and Doctrine 1.2.4 you need to make the following changes:

In databases.yml:

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      odbc:DRIVER={SQL Server Native Client 10.0};Server=SERVER.database.windows.net;Database=DATABASE;Encrypt=yes;
      username: USERNAME@SERVER
      password: PASSWORD

Sadly there appeard some ugly errors, but I could fix them (please don’t ask me how I found the solutions).

The first error appeared trying to build the model:

When using the attribute ATTR_AUTO_ACCESSOR_OVERRIDE you cannot use the field name “defaultculture” because it is reserved by Doctrine. You must cho
ose another field name.

In my case it’s not possible to change the field name because the DB schema is not under my control. To solve this I did the follwing changes:

In symfony/lib/plugins/sfDoctrinePlugin/config/sfDoctrinePluginConfiguration.class.php deactivate the setting ATTR_AUTO_ACCESSOR_OVERRIDE:

$manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, false);

And in symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Mssql.php I had to change:

    public function listTableColumns($table)
    {
        #$sql = 'EXEC sp_primary_keys_rowset @table_name = ' . $this->conn->quoteIdentifier($table, true);
        $sql = 'EXEC sp_pkeys @table_name = ' . $this->conn->quoteIdentifier($table, true);

The changes inside the Doctrine Plugin are not clean, it should be an accrodingly extension, but it worked for my quick requirement to generate a schema out of the database.

EDIT:

For some reason I got again an error while trying to build the schema out of the SQL Azure database:

SQLSTATE[42000]: Syntax error or access violation: 156 [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword ‘File’. (SQLExecute[156] at ext\pdo_odbc\odbc_stmt.c:254). Failing Query: “EXEC sp_pkeys @table_name = File”

and

SQLSTATE[42000]: Syntax error or access violation: 156 [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near the keyword ‘File’. (SQLExecute[156] at ext\pdo_odbc\odbc_stmt.c:254). Failing Query: “EXEC sp_columns @table_name = File”

To solve the problem I need to modifie the change I did in

symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Import/Mssql.php:

    public function listTableColumns($table)
    {
        #$sql = 'EXEC sp_primary_keys_rowset @table_name = ' . $this->conn->quoteIdentifier($table, true);
        $sql = 'EXEC sp_pkeys @table_name = ' . $this->conn->quoteIdentifier($table, false);
        ...
        #$sql     = 'EXEC sp_columns @table_name = ' . $this->conn->quoteIdentifier($table, true);
        $sql     = 'EXEC sp_columns @table_name = ' . $this->conn->quoteIdentifier($table, false);

I changed the 2nd quoteIdentifier parameter to “false“.