You can execute the following T-SQL query: SELECT DATABASEPROPERTYEX ('', 'Updateability'). The result is READ_ONLY if you are connected to a read-only secondary replica, and READ_WRITE if you are connected to the primary replica. Note that the database context must be set to the name of your database, not to the master database.