Annotations for "CREATE SCHEMA (Transact-SQL)" topic.Fri, 09 Dec 2016 16:37:17 Zhttp://msdn.microsoft.com/en-US/library/ms189462(v=sql.105).aspx#CommunityContent
Niels Grove-RasmussenAvoid DROP-CREATEA DROP-CREATE of a schema will fail, if a object exist in the schema. If a structure is scripted, the schema is needed.
A CREATE SCHEMA statement can not be conditional, but this can be done indirect byIF EXISTS (SELECT [schema_id] FROM [sys].[schemas] WHERE [name] = N'sprockets')BEGINPRINT N'Schema sprockets exists.';ENDELSE BEGINEXECUTE ('CREATE SCHEMA [sprockets] AUTHORIZATION [dbo];');PRINT N'Schema sprockets created.';ENDTue, 10 Aug 2010 08:58:41 -0700http://msdn.microsoft.com/en-US/library/ms189462(v=sql.105).aspx#CommunityContent
Craig Beere, MCTSample code does not do what you thinkThe example code is one of the looniest pieces of code you'll find in SQL Server. CREATE SCHEMA Sprockets AUTHORIZATION AnnikCREATE TABLE NineProngs (source int, cost int, partnumber int)GRANT SELECT TO MandarDENY SELECT TO Prasanna;This (possibly) does not do what you think it does. It is one statement that performs the following:• Creates a schema called Sprockets, owned by Annik.• Creates a table called Sprockets.NineProngs, owned by Annik.• Grants select permission on the database (not on thTue, 08 Jun 2010 01:42:29 -0700