Systems Admin

SQL Always On Availability Groups Part 4: Enable Always On + Create the Database

SQL Server is installed on both nodes (Part 2) and the WSFC is up (Part 3). Two more prerequisites before we can build the AG itself:

  1. Enable the Always On feature on both SQL instances (it’s OFF by default after install)
  2. Create the database we’re going to put in the AG, set it to FULL recovery, and take a full backup

Both of these happen in this part. Almost everything is on SQL-NODE-01 only — SQL-NODE-02 just needs the Always On enable + restart. The database itself doesn’t need to be created on SQL-NODE-02 manually; SQL ships it over when we add the database to the AG in Part 5.

Enable Always On in SQL Server Configuration Manager

Always On Availability Groups is an opt-in feature. After install, it’s sitting there disabled, waiting for you to flip the bit per instance.

SQL Server Configuration Manager on SQL-NODE-01 with the SQL Server service properties dialog open and Enable AlwaysOn Availability Groups checkbox ticked
On SQL-NODE-01, open SQL Server Configuration Manager > SQL Server Services > right-click SQL Server (MSSQLSERVER) > Properties > AlwaysOn High Availability tab > tick Enable AlwaysOn Availability Groups > Apply.

On SQL-NODE-01: Start menu > SQL Server Configuration Manager (or SQLServerManager16.msc) > SQL Server Services > right-click SQL Server (MSSQLSERVER) > Properties > AlwaysOn High Availability tab > tick Enable AlwaysOn Availability Groups > Apply.

You’ll see the WSFC name (SQLCLUSTER01) auto-detected at the top — that’s how SQL Server knows it can use this cluster as the underlying coordination layer. If WSFC isn’t detected here, the cluster wasn’t built correctly in Part 3 — go back and fix it.

SQL Server Configuration Manager with the SQL Server service being restarted to apply the AlwaysOn enable change
After Apply, you must restart the SQL Server service for the change to take effect. Right-click the service > Restart.

The setting needs a SQL service restart to take effect. Right-click SQL Server (MSSQLSERVER) > Restart.

Repeat on SQL-NODE-02

SQL Server Configuration Manager on SQL-NODE-02 with the same Enable AlwaysOn Availability Groups checkbox being ticked on the second node
Now do the exact same two steps on SQL-NODE-02. Tick the box.

Same flow on SQL-NODE-02: Configuration Manager > tick the AlwaysOn box > Apply.

SQL Server service restart on SQL-NODE-02 to commit the AlwaysOn enable change on the secondary node
Restart SQL Server on SQL-NODE-02. Without this on both nodes, the AG wizard refuses to launch in Part 5.

Restart SQL Server on SQL-NODE-02.

Both nodes must have AlwaysOn enabled. If only one has it, the AG wizard in Part 5 will fail to add the secondary replica.

Open SSMS and connect

SQL Server Management Studio splash and Connect to Server dialog being launched on SQL-NODE-01
On SQL-NODE-01, open SSMS.

On SQL-NODE-01, launch SQL Server Management Studio.

Connect to Server dialog with the SQL-NODE-01 instance and Windows authentication selected and Connect button clicked
Connect to the local instance (server name = SQL-NODE-01, Windows authentication).

Connect to Server: type SQL-NODE-01 as the server name (default instance, no instance suffix needed). Authentication: Windows Authentication. Connect.

Create the demo database

Object Explorer with SQL-NODE-01 right-clicked and the New Query option selected to open a query window
Right-click the SQL-NODE-01 server node in Object Explorer > New Query.

Right-click the SQL-NODE-01 server node in Object Explorer > New Query.

New Query window showing the CREATE DATABASE demodb statement being executed against the SQL-NODE-01 instance
Run CREATE DATABASE demodb; — this creates the test database that we’ll add to the AG.

Run:

CREATE DATABASE demodb;
GO

ALTER DATABASE demodb SET RECOVERY FULL;
GO

The FULL recovery model is non-negotiable for AG. Always On replicates transaction log records between replicas; SIMPLE recovery doesn’t generate the persistent log SQL needs to ship. If your database is in SIMPLE recovery when you try to add it to an AG, the wizard rejects it.

Object Explorer Databases node refreshed showing the new demodb database alongside the system databases
Refresh Databases — demodb is now visible alongside the system databases.

Refresh Databases — demodb is now visible.

Create a table and insert seed data

New Query window targeting demodb running a CREATE TABLE statement to create the dbo.Employees table
Switch to demodb (USE demodb;) > New Query > create a table. The exact T-SQL is in the body below.

Right-click demodb > New Query. Run:

USE demodb;
GO

CREATE TABLE dbo.Employees (
    id   INT          PRIMARY KEY,
    name VARCHAR(50)  NOT NULL,
    role VARCHAR(50)  NULL
);
GO
New Query window with INSERT statements adding several rows of seed data into the dbo.Employees table
Insert seed rows so we have something to verify replication with later.

Insert some test rows so we can verify replication later:

INSERT INTO dbo.Employees (id, name, role) VALUES
    (1, 'Alice',   'DBA'),
    (2, 'Bob',     'SysAdmin'),
    (3, 'Charlie', 'Developer');
GO
New Query window with a SELECT statement returning the rows just inserted into the demodb dbo.Employees table
Run a SELECT to confirm the rows are there.

Verify:

SELECT * FROM dbo.Employees;

You should see 3 rows.

Take a full backup — required before AG join

SQL Server requires a database to have at least one full backup before it can be added to an AG. The reason: when SQL seeds the database to the secondary replica, it needs a recoverable starting point. No full backup = no AG.

Right-click context menu on demodb showing the Tasks submenu with the Back Up option highlighted
Right-click demodb > Tasks > Back Up… A FULL backup is REQUIRED before SQL will let you add the database to an AG.

Right-click demodb > Tasks > Back Up…

Back Up Database dialog with backup type set to Full and OK clicked to write the demodb full backup file
Backup type: Full. Path: e.g. C:\Backups\demodb.bak. OK. Confirms backup succeeded. Now you’re ready for Part 5.

Backup type: Full. Destination: a path like C:\Backups\demodb.bak (create the folder first if needed). OK.

You’ll see “BACKUP DATABASE successfully processed.” The .bak file lands at the path you specified.

You don’t need to do anything on SQL-NODE-02 in this part. No database creation, no backup. The AG wizard will handle seeding to SQL-NODE-02 in the next step.

Things that bite people

SIMPLE recovery model

If demodb is in SIMPLE recovery, the AG wizard greys it out. Always switch to FULL recovery before taking the full backup — if you backup-then-switch, the recovery chain starts from a non-FULL backup which the AG won’t accept.

No full backup taken

Same wizard greying. Take a full backup AFTER setting FULL recovery, before opening the AG wizard.

Forgot to enable AlwaysOn on SQL-NODE-02

The AG creation succeeds with just the primary, but adding SQL-NODE-02 as a replica fails with The local replica of availability group is not in a state that could process this command. Go back, enable AlwaysOn on SQL-NODE-02, restart SQL, retry.

Forgot to restart SQL after enabling AlwaysOn

Apply doesn’t mean live — SQL Server picks up the setting on next startup. Symptom: AG wizard says “Always On not enabled” even though Configuration Manager shows the box ticked. Restart SQL service.

Created the database on SQL-NODE-02 too

Don’t. AG init will fail because there’s already a same-named database on the secondary. Drop it from SQL-NODE-02 and let the AG wizard handle the seed.

Database name collision with demodb

If a leftover demodb exists from a previous attempt, drop it first: DROP DATABASE demodb; Then re-create cleanly.

What’s next

Part 5 in the SQL Availability Groups pathway: open the New Availability Group Wizard in SSMS, name the AG, add demodb, add SQL-NODE-02 as a synchronous secondary replica, and create the listener VNN that applications will connect to.

Leave a Reply