Support Thread

Error Messages While Setting Up The Database Script

Error Messages While Setting Up The Database Script — APG vNext Guide

Error Messages While Setting Up The Database Script — this archived support thread from the APG vNext community covers a reported issue and its resolution.

Troubleshooting This Issue

  1. Set customErrors mode="Off" in web.config to expose the full error and stack trace.
  2. Check Windows Event Viewer → Application log for ASP.NET exceptions.
  3. Review Admin Panel → Logs → Error Log for timestamped application errors.
  4. Restart the IIS Application Pool to clear stale state.
  5. Verify the database connection string and run any pending upgrade SQL scripts.

Related Resources

Database Setup Script Errors in APG vNext Installation

Running the APG vNext database setup script (apg-schema.sql) can fail with various SQL Server errors. This guide covers the most common script errors with exact causes and fixes.

Error: "Database 'ForumDB' does not exist"

-- Create the database first:
CREATE DATABASE ForumDB
COLLATE SQL_Latin1_General_CP1_CI_AS;
GO
USE ForumDB;
GO
-- Then run the setup script

Error: "Full-text search is not installed"

-- Verify full-text is installed:
SELECT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled');
-- Returns 1 if installed, 0 if not

-- If not installed:
-- Run SQL Server setup and add "Full-Text and Semantic Extractions" feature
-- Then enable on the database:
EXEC sp_fulltext_database 'enable';

Error: "Permission denied - CREATE TABLE"

The database user running the script lacks DDL permissions. Fix:

-- Grant DDL rights for setup (remove after installation):
ALTER ROLE db_owner ADD MEMBER [apguser];
-- Run setup script
-- After setup, reduce to minimum permissions:
ALTER ROLE db_owner DROP MEMBER [apguser];
EXEC sp_addrolemember 'db_datareader', 'apguser';
EXEC sp_addrolemember 'db_datawriter', 'apguser';

Error: "Cannot drop the table 'apg_X' because it does not exist"

The setup script checks for existing tables before dropping. This error appears when re-running the script on a partially initialised database. Drop all APG tables manually first:

-- Drop all APG tables (order matters for FK constraints):
EXEC sp_MSforeachtable
  'IF OBJECT_ID(''?'') IS NOT NULL AND ''?'' LIKE ''%apg_%'' DROP TABLE ?'

Running the Setup Script Against Azure SQL

APG vNext database setup scripts include features not supported by Azure SQL (e.g., EXEC sp_MSforeachtable, certain SQL Server Agent steps, and Windows Authentication–specific syntax). When installing APG vNext against Azure SQL Database, use the Azure SQL–specific setup script variant provided in the /install/sql/azure/ folder. Key differences include: using CONTAINED DATABASE AUTHENTICATION instead of Windows Auth, using Azure SQL compatible syntax for full-text search (full-text is supported in Azure SQL but the enabling syntax differs from on-premises SQL Server), and removing any filegroup-specific DDL that references PRIMARY filegroup explicitly.

Character Set and Collation Errors

APG vNext requires the database to use a case-insensitive collation (_CI_ in the collation name). If the SQL Server instance default collation is case-sensitive (_CS_), create the APG vNext database with an explicit collation override to avoid case-sensitivity errors when APG vNext queries its own tables:

CREATE DATABASE ForumDB
  COLLATE SQL_Latin1_General_CP1_CI_AS;
-- CI_AS = Case Insensitive, Accent Sensitive
-- Required for APG vNext stored procedures to function correctly

Script Execution Order

The APG vNext database setup package includes multiple SQL scripts that must be run in order: first the schema script (apg-schema.sql) that creates all tables and constraints, then the stored procedures script (apg-procedures.sql) that creates stored procedures referencing the tables, then the seed data script (apg-data.sql) that inserts default configuration values. Running them out of order causes foreign key constraint violations or stored procedures that reference non-existent tables. Always run in the documented order and verify each script completes without errors before running the next.

Verifying Successful Setup

-- Verify all APG tables were created:
SELECT COUNT(*) AS TableCount FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE 'apg_%';
-- Successful install creates 17+ tables

-- Verify default settings were inserted:
SELECT COUNT(*) AS SettingCount FROM apg_Settings;
-- Should be 50+ rows after seed data script

Post-Setup Verification Queries

After the database setup script completes without errors, run a brief verification to confirm all tables, stored procedures, and seed data are present before deploying the APG vNext application files. A missing stored procedure or incorrect seed data row causes errors that only surface when a specific feature is used, potentially going unnoticed until a member reports a problem. The verification takes under one minute and catches incomplete setups immediately when they are easiest to fix. Document the verification output in your deployment log so you have a baseline record of the initial database state to compare against if problems arise later during operation.

Shared Hosting Limitations for APG vNext Database Setup

Shared hosting SQL Server instances often restrict the database user's DDL permissions, preventing the APG vNext setup script from creating tables. On a shared hosting plan, the hosting provider typically runs the database setup script on your behalf, or provides a control panel interface for importing SQL scripts with elevated privileges. If you are using a shared hosting plan, contact your hosting provider's support team with the APG vNext database setup script (apg-schema.sql) and request that they run it against your allocated database. Alternatively, upgrade to a VPS or dedicated server plan that provides full SQL Server access, which is recommended for production APG vNext forums for performance reasons in any case. For development and evaluation purposes, SQL Server Express edition running locally provides full DDL permissions and is free for databases under 10 GB.

Related Resources


Looking for more help? Browse the support forum or check the Knowledge Base.