Gallery2:MSSQL - Gallery Codex
Personal tools


From Gallery Codex

Microsoft SQL Server For Gallery 2

Gallery 2 supports Microsoft SQL Server (version 2005 and later) as a database backend as of Gallery 2.2.

  • Full testing has been done using SQL Server 2005 Express Edition (which is a free download from Microsoft). Pre-2005 versions are known to not work completely (e.g. SQL Server 7 does not work with the linkitem module, and most likely not with certain, basic core functions).


  • Missing UTF-8 support (UCS-2 instead) - MS SQL Server is the only Gallery 2 database backend that does not support UTF-8. MS SQL Server uses UCS-2 to encode unicode characters instead. UCS-2 is a 2-byte locale-dependent encoding. That means that it can store all characters for the configured language (locale), but not for other languages at the same time. All other database backends for Gallery 2 can store strings for all languages at the same time.
  • Limited testing - MS SQL Server is the latest addition to the list of supported database backends of Gallery 2. It's not used by any Gallery 2 developer as the main development platform and the userbase is very small at this point. Thus you cannot expect the same stability as from e.g. G2/MySQL or G2/PostgreSQL which are used by thousands of users and during development. Nevertheless, we run a large set of unit tests on all supported platforms for each release, including MS SQL Server / Windows XP.

Database Creation Steps (Before running the Installer)

  • To create a "gallery2" database from scratch, put the following statements into a file (called, for example, "create_Gallery2.sql"), substituting your Gallery 2 account information for "g2user" and "g2pwd":
create database gallery2
use gallery2
create schema g2user
create login g2user with password = "g2pwd"
create user g2user for login g2user with default_schema = g2user

Run the statements in that file using the "sqlcmd" command line interface:

"sqlcmd -S myhostname\SQLEXPRESS -e -i create_Gallery2.sql"

Your database should now be ready for the Gallery 2 Installer.

For more Microsoft SQL Server documentation, see

  • At Step 5 of the Installer ("Database Setup" step), in the "Hostname" field, enter your hostname and append "\SQLEXPRESS". For example, "myhostname\SQLEXPRESS".