Database_Id for our database in sys.databases does not match that of DB_ID ( '<our database' )
Azure SQL DB is different !

The database_id column from sys.databases (dont use sysdatabases &lt;-- its deprecated) will remain the same for the database.

The DB_ID() is a function and the value will change if the Azure DB is failed over.

Best is to use name &lt;-- database name column.

People have reported that here and here.


  One shouldn't rely on database id / db_id builtin in azure as it changes whenever database moves to a different sql instance (because of the database failover). Use name instead of the id. Also please note that the db_id can potentially be different than in the sys.databases