{"id":4369,"date":"2013-02-01T14:49:43","date_gmt":"2013-02-01T14:49:43","guid":{"rendered":"http:\/\/craftydba.com\/?p=4369"},"modified":"2013-02-06T02:35:53","modified_gmt":"2013-02-06T02:35:53","slug":"user-design-with-ssms","status":"publish","type":"post","link":"https:\/\/craftydba.com\/?p=4369","title":{"rendered":"User Design with SSMS"},"content":{"rendered":"<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/user_icon.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/user_icon.jpg\" alt=\"\" title=\"user_icon\" width=\"128\" height=\"128\" class=\"alignleft size-full wp-image-4370\" \/><\/a><\/p>\n<p>Most of the articles that I presented so far for database development have been centered around the exact Microsoft T-SQL syntax to perform a certain operation.  At the <a href=\"http:\/\/www.cs.uri.edu\/\">University of Rhode Island<\/a>, I learnt how to program in Pascal before typing in my first ANSI SQL statement.  In short, I will always be some type of developer in my heart.  <\/p>\n<p>However, many people do not come from a computer science and math background.  The SQL Server Management Studio (<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb934498.aspx\">SSMS<\/a>) has menus and dialog boxes to achieve many of the same results.  <\/p>\n<p>Today, I am going to continue the series of articles that will recreate the [AUTOS] sample database while demonstrating how common T-SQL tasks in my <a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/designing-with-ssms.sql_.txt\">script<\/a> can be done with SSMS.  I will be going over sections 1F to 1H in the sample code.<\/p>\n<p>I want to explore how the <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms189751.aspx\">CREATE LOGIN<\/a>, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms189835.aspx\">DROP LOGIN<\/a>, <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms173463.aspx\">CREATE USER<\/a>, and <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms190290.aspx\">DROP USER<\/a> statements can be executed within SSMS.<\/p>\n<p>Security in Microsoft SQL Server is based upon the idea that principals are given rights to securables.  <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms181127.aspx\">Principals<\/a> in the most basic sense are server logins and database users.  <\/p>\n<p><a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms190401.aspx\">Securables<\/a> are any object such as table, view, function, procedure, and etc in which a database user can be GRANTED, DENIED, or REVOKED rights.  <\/p>\n<p>Please see the MSDN permissions hierarchy <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ms191465.aspx\">diagram<\/a> below.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/permission-hierarchy.gif\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/permission-hierarchy.gif\" alt=\"\" title=\"permission-hierarchy\" width=\"531\" height=\"689\" class=\"aligncenter size-full wp-image-4379\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/permission-hierarchy.gif 531w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/permission-hierarchy-231x300.gif 231w\" sizes=\"auto, (max-width: 531px) 100vw, 531px\" \/><\/a><\/p>\n<p>Our task today is to add two server logins named [AUTOS_USER] which has read rights to the database and [AUTOS_ADMIN] which has read &#038; write rights to the database.  <\/p>\n<p>To create a new server login, find the logins node under server security in the object explorer.  Right click and select New Login.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-SECURITY-ADD-NEW-LOGIN.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-SECURITY-ADD-NEW-LOGIN.jpg\" alt=\"\" title=\"SSMS-SECURITY-ADD-NEW-LOGIN\" width=\"427\" height=\"252\" class=\"aligncenter size-full wp-image-4383\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-SECURITY-ADD-NEW-LOGIN.jpg 427w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-SECURITY-ADD-NEW-LOGIN-300x177.jpg 300w\" sizes=\"auto, (max-width: 427px) 100vw, 427px\" \/><\/a><\/p>\n<p><span style=\"color: #FF0000;\">First<\/span>, lets take a look at the detailed choices that need to be made for the [AUTOS_USER]. <\/p>\n<p>Make sure the radio button for SQL Server Authentication is selected.  Enter the correct login name and password.  Make sure the password options are unselected since we do not want to enforce password policy, enforce password expiration or make the user change the password at next login.  Last but not least, make sure the default database is [AUTOS].  <\/p>\n<p>We now supplied enough information for SSMS to create a server login (<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms189751.aspx\">CREATE LOGIN<\/a>).<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-1.jpg\" alt=\"\" title=\"SSMS-AUTOS-USER-SERVER-LOGIN-1\" width=\"704\" height=\"630\" class=\"aligncenter size-full wp-image-4387\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-1.jpg 704w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-1-300x268.jpg 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><\/p>\n<p>Find the user mapping page on the right side of the new login dialog box.  <\/p>\n<p>Map the new login to the [AUTOS] database as a user.  As a default, the user will be in the public database role.  Add the user to the db_datareader role and map the user to the [ACTIVE] schema.  This can be done by entering the correct schema name or using the search boxes to bring up a list of schemas.<\/p>\n<p>We now supplied enough information for SSMS to create a database user (<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ms173463.aspx\">CREATE USER<\/a>).<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-2.jpg\" alt=\"\" title=\"SSMS-AUTOS-USER-SERVER-LOGIN-2\" width=\"1223\" height=\"632\" class=\"aligncenter size-full wp-image-4388\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-2.jpg 1223w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-2-300x155.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-USER-SERVER-LOGIN-2-1024x529.jpg 1024w\" sizes=\"auto, (max-width: 1223px) 100vw, 1223px\" \/><\/a><\/p>\n<p><span style=\"color: #FF0000;\">Second<\/span>, we need to repeat the same detailed choices for the [AUTOS_ADMIN] server login. <\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-1.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-1.jpg\" alt=\"\" title=\"SSMS-AUTOS-ADMIN-SERVER-LOGIN-1\" width=\"704\" height=\"632\" class=\"aligncenter size-full wp-image-4394\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-1.jpg 704w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-1-300x269.jpg 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><\/p>\n<p>We need to repeat the same detailed choices for the [AUTOS_ADMIN] database user.  <\/p>\n<p>The only changes are a default schema of [STAGE] and a additional database role of db_datawriter.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-2.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-2.jpg\" alt=\"\" title=\"SSMS-AUTOS-ADMIN-SERVER-LOGIN-2\" width=\"1219\" height=\"633\" class=\"aligncenter size-full wp-image-4395\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-2.jpg 1219w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-2-300x155.jpg 300w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-ADMIN-SERVER-LOGIN-2-1024x531.jpg 1024w\" sizes=\"auto, (max-width: 1219px) 100vw, 1219px\" \/><\/a><\/p>\n<p>Let&#8217;s take a look at the results of our hard labor.  <\/p>\n<p>Go to the Logins node under Server Security in the object explorer.  Expand the logins node to see all the members.  Both the [AUTOS_ADMIN] and [AUTOS_USERS] server login do exist.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-SERVER-LOGINS.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-SERVER-LOGINS.jpg\" alt=\"\" title=\"SSMS-AUTOS-VIEW-SERVER-LOGINS\" width=\"421\" height=\"336\" class=\"aligncenter size-full wp-image-4400\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-SERVER-LOGINS.jpg 421w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-SERVER-LOGINS-300x239.jpg 300w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/a><\/p>\n<p>To find out if we created our database users correctly, drill into the [AUTOS] database in the object explorer pane.  Go to the Users node under database Security.  Expand the users node to see all the members.   Both the [AUTOS_ADMIN] and [AUTOS_USERS] database users do exist.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-DATABASE-USERS.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-DATABASE-USERS.jpg\" alt=\"\" title=\"SSMS-AUTOS-VIEW-DATABASE-USERS\" width=\"401\" height=\"395\" class=\"aligncenter size-full wp-image-4401\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-DATABASE-USERS.jpg 401w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-VIEW-DATABASE-USERS-300x295.jpg 300w\" sizes=\"auto, (max-width: 401px) 100vw, 401px\" \/><\/a><\/p>\n<p>To complete our test of designing users with SSMS, we need to drop the database user then server login.  <\/p>\n<p>Find the [AUTOS_USER] database user under the logins node in the object explorer.  Right click and select delete.  The delete object dialog box will appear.  Selecting the OKAY button will remove the database user.<\/p>\n<p><a href=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-DEL-USER-DB-LOGIN.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-DEL-USER-DB-LOGIN.jpg\" alt=\"\" title=\"SSMS-AUTOS-DEL-USER-DB-LOGIN\" width=\"704\" height=\"631\" class=\"aligncenter size-full wp-image-4408\" srcset=\"https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-DEL-USER-DB-LOGIN.jpg 704w, https:\/\/craftydba.com\/wp-content\/uploads\/2013\/02\/SSMS-AUTOS-DEL-USER-DB-LOGIN-300x268.jpg 300w\" sizes=\"auto, (max-width: 704px) 100vw, 704px\" \/><\/a><\/p>\n<p>I will leave deleting the [AUTOS_USER] server login as an exercise for you to-do.<\/p>\n<p>In summary, we can do many of the Data Definition Language (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Data_definition_language\">DDL<\/a>) tasks that can be done in T-SQL. The cool script button shows you what SQL Server Management Studio (<a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/bb934498.aspx\">SSMS<\/a>) will use for code to accomplish a particular task. Next time, I will be talking about creating user defined tables with SSMS.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of the articles that I presented so far for database development have been centered around the exact Microsoft T-SQL syntax to perform a certain operation. At the University of Rhode Island, I learnt how to program in Pascal before typing in my first ANSI SQL statement. In short, I will always be some type of developer in my heart. However, many people do not come from a computer science and math background. The SQL Server Management Studio (SSMS) has menus and dialog boxes to achieve many of the same&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[56,59,391,749,58,60,12,15,750,751,28,741,470],"class_list":["post-4369","post","type-post","status-publish","format-standard","hentry","category-db-dev","tag-create-login","tag-create-user","tag-ddl","tag-designing-users","tag-drop-login","tag-drop-user","tag-free-code","tag-john-f-miner-iii","tag-principles","tag-securables","tag-sql-server","tag-sql-server-management-studio","tag-ssms"],"_links":{"self":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/4369","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4369"}],"version-history":[{"count":0,"href":"https:\/\/craftydba.com\/index.php?rest_route=\/wp\/v2\/posts\/4369\/revisions"}],"wp:attachment":[{"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/craftydba.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}