I’ve been looking at the shiny new things in SQL Server 2014, now that the CTP2 is out and after my post on SQL Server Agent jobs AlwaysOn and SQL Agent Jobs which used management views to see if the current server was the primary replica.
Now in SQL Server 2014 we are going to get a function to do it for us sys.fn_hadr_is_primary_replica http://technet.microsoft.com/en-us/library/dn249345(v=sql.120).aspx
Finding primary replica – SQL Server 2014