As part of our build process we run a database update script as we deploy code to 4 different environments. Further, since the same query will get added to until we drop a r
@bdukes is right on the money for determining if the schema exists, but the statement above won't work in SQL Server 2005. CREATE SCHEMA needs to run in its own batch. A work around is to execute the CREATE SCHEMA statement in an exec.
Here is what I used in my build scripts:
IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = '')
BEGIN
-- The schema must be run in its own batch!
EXEC( 'CREATE SCHEMA ' );
END