Preparing a NAM Console database

When you install the NAM Console, the installer gives you the following database options:

  • Create new database
    Select this option to have the installer create a new SQL Server database for the NAM Console. This is the easiest and most reliable way to create a database. The installer will:
    • Create a database
    • Create an MS SQL server login
    • Create a database user and schema
  • Use existing database
    Select this option if you are installing or reinstalling the console and you already have a database from the previous installation. The installer will upgrade your database as needed.

Those are the recommended options. If you can use either of them, you don't need to continue with this topic.

If you don't have a database but you can’t use the installer to create a database automatically (perhaps due to your local security requirements), however, neither option is available to you. In this case, you need to ask your local SQL Server database administrator with CONTROL SERVER permissions to carry out the procedures described in this topic to create a database for you. After the database is created and you have access to it, you can run the NAM Console installer and select Use existing database to point to that database.

Creating a NAM Console database

Use the following statements to create a new database using Microsoft SQL Server Management Studio.

Note: $DB_NAME is the database name.

USE [master]
GO
CREATE DATABASE [$DB_NAME]
GO
ALTER DATABASE [$DB_NAME] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [$DB_NAME] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [$DB_NAME] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [$DB_NAME] COLLATE SQL_Latin1_General_CP1_CI_AS
GO

Creating an MS SQL server login

Use the following statements to create an MS SQL server login.

Note:

  • $LOGIN is the MSSQL database login
  • $PASSWD is the login's password
  • $DOMAIN is the Windows domain name

For SQL server authentication:

IF NOT EXISTS (SELECT * FROM syslogins WHERE name='$LOGIN')
BEGIN
	CREATE LOGIN [$LOGIN] WITH PASSWORD=N'$PASSWD', DEFAULT_DATABASE=[$DB_NAME], CHECK_EXPIRATION=OFF, CHECK_POLICY=OFF
END
GO

For Windows authentication:

USE [master]
GO
IF NOT EXISTS (SELECT * FROM syslogins WHERE name='$DOMAIN\$LOGIN')
BEGIN
	CREATE LOGIN [$DOMAIN\$LOGIN] FROM WINDOWS WITH DEFAULT_DATABASE=[$DB_NAME]
END
GO

Creating a database user and schema

Use the following statements to create a database user and schema.

For SQL server authentication:

USE [$DB_NAME]
GO
EXEC sp_changedbowner 'sa'
GO
CREATE USER [$LOGIN] FOR LOGIN [$LOGIN] WITH DEFAULT_SCHEMA=[$LOGIN]
GO
CREATE SCHEMA [$LOGIN] AUTHORIZATION [$LOGIN]
GO
EXEC sp_addrolemember N'db_owner', N'[$LOGIN]'

For Windows authentication:

USE [$DB_NAME]
GO
EXEC sp_changedbowner 'sa'
GO
CREATE USER [$DOMAIN\$LOGIN] FOR LOGIN [$DOMAIN\$LOGIN] WITH DEFAULT_SCHEMA=[$DOMAIN\$LOGIN]
GO
CREATE SCHEMA [$DOMAIN\$LOGIN] AUTHORIZATION [$DOMAIN\$LOGIN]
GO
EXEC sp_addrolemember N'db_owner', N'[$DOMAIN\$LOGIN]'

What to do next

If you have created your own database, login, user, and schema as described above, you should now run the NAM Console installer, select Use existing database, and point the installer to the database.