How do I query if a database schema exists
Are you looking for sys.schemas? IF NOT EXISTS (SELECT * FROM sys.schemas WHERE name=”jim”) BEGIN EXEC(‘CREATE SCHEMA jim’) END Note that the CREATE SCHEMA must be run in its own batch (per the answer below)