{"id":58,"date":"2012-02-16T12:05:30","date_gmt":"2012-02-16T17:05:30","guid":{"rendered":"http:\/\/myplace.bluecastle.us\/?p=58"},"modified":"2012-02-16T12:05:30","modified_gmt":"2012-02-16T17:05:30","slug":"schemas-and-sql-server-2005","status":"publish","type":"post","link":"http:\/\/myplace.bluecastle.us\/?p=58","title":{"rendered":"Schemas and SQL Server 2005"},"content":{"rendered":"<p>Here it is 2012 already and I am just starting to play with schemas in SQL 2005.  Anyway, follow the directions below to just start using a Schema as a container or namespace for your objects.<\/p>\n<ol>\n<li>Create a Role &#8220;schema_owner&#8221; and set the owner to dbo.<\/li>\n<li>Create schema &#8220;myschema&#8221; and set the owner to &#8220;schema_owner&#8221;.\u00a0 I personally used the same word for both the schema and the role.   ex:   Role=&#8221;myschema&#8221;;  Schema=&#8221;myschema&#8221;.<\/li>\n<\/ol>\n<p>Now, logged in as SA with default permissions:<\/p>\n<ul>\n<li>I can create, alter, select, etc. any objects to the new schema as long as a schema qualify my objects.<\/li>\n<li>Red-Gate&#8217;s SQL Prompt can &#8216;see&#8217; the schema and related objects for proper prompting.<\/li>\n<\/ul>\n<p>At first I started with only a schema that was owned by &#8220;dbo&#8221;.\u00a0 I could create tables and query tables, but SQL Prompt would not suggest those objects.\u00a0 After playing around, I tried duplicating one of the other default schemas like db_accessadmin or db_owner.\u00a0 Once the shema is owned by the role and the role is owned by dbo, then SQL Prompt works as expected.<\/p>\n<p>Bonus:\u00a0\u00a0 Name Resolution according to Bob Beauchemin at <a href=\"http:\/\/www.sqlskills.com\/BLOGS\/BOBB\/post\/Dude-wheres-my-table.aspx\" target=\"_blank\">http:\/\/www.sqlskills.com\/BLOGS\/BOBB\/post\/Dude-wheres-my-table.aspx<\/a><\/p>\n<ol>\n<li>sys schema<\/li>\n<li>user&#8217;s default schema or the stored procedure schema<\/li>\n<li>dbo schema<\/li>\n<\/ol>\n<p>Go check out Bob&#8217;s post as he has several posts related to schemas that are very informative.<\/p>\n<p>Also, if you havn&#8217;t heard of SQL Prompt, you can learn more <a title=\"http:\/\/www.red-gate.com\" href=\"http:\/\/www.red-gate.com\/products\/sql-development\/sql-prompt\/\" target=\"_self\">here<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Here it is 2012 already and I am just starting to play with schemas in SQL 2005. Anyway, follow the directions below to just start using a Schema as a container or namespace for your objects. Create a Role &#8220;schema_owner&#8221; and set the owner to dbo. Create schema &#8220;myschema&#8221; and set the owner to &#8220;schema_owner&#8221;.\u00a0 I personally used the same&hellip; <a href=\"http:\/\/myplace.bluecastle.us\/?p=58\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-58","post","type-post","status-publish","format-standard","hentry","category-sql","xfolkentry"],"_links":{"self":[{"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=\/wp\/v2\/posts\/58","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=58"}],"version-history":[{"count":0,"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=\/wp\/v2\/posts\/58\/revisions"}],"wp:attachment":[{"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=58"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=58"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/myplace.bluecastle.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=58"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}