{"id":26497,"date":"2023-06-07T05:07:00","date_gmt":"2023-06-07T03:07:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=26497"},"modified":"2023-08-08T17:08:11","modified_gmt":"2023-08-08T15:08:11","slug":"manage-sql-server-security","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/","title":{"rendered":"How to manage SQL Server security with scripts?"},"content":{"rendered":"\n<p>In any database system, is of utmost importance to properly manage SQL Server security. It is the cornerstone of protecting sensitive data and ensuring that only authorized personnel can access and modify it. In the context of SQL Server databases projects, a robust and comprehensive security strategy involves multiple components, including server logins, database users, roles, schemas, and object-level permissions.<\/p>\n\n\n\n<p>By correctly implementing these components, you can create an environment that balances accessibility and security, allowing the right people to access the right data at the right times, while keeping unwanted intruders out of the system. However, setting up the security infrastructure is only the beginning. Regular auditing, review, and updates to the security settings are vital to maintain a secure environment, as the landscape of threats is ever-evolving.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 ez-toc-wrap-center counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#1-sql-server-security-introduction\" >1. SQL Server Security introduction<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#2-manage-the-server-logins\" >2. Manage the Server Logins<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#3-manage-the-database-users\" >3. Manage the Database Users<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#4-assign-specific-object-level-permissions\" >4. Assign specific Object level permissions<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#5-manage-roles\" >5. Manage Roles<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#6-manage-sql-server-schemas\" >6. Manage SQL Server Schemas<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-sql-server-security-introduction\"><span class=\"ez-toc-section\" id=\"1-sql-server-security-introduction\"><\/span>1. SQL Server Security introduction<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>In SQL Server, security administration involves managing server and database level security objects including logins, users, roles, and schemas. Whenever on premise or line, <a href=\"https:\/\/nindohost.ma\/en\/blog\/importance-of-the-ssl-certificate-for-your-site\/\" target=\"_blank\" rel=\"noreferrer noopener\">security is the top priority<\/a> since the development and democratization of smartphones and mobility.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Server Logins<\/strong>: These are the identities that can connect to the SQL Server instance. They could be Windows logins, SQL Server logins, Windows groups or certificates.<\/li>\n\n\n\n<li><strong>Database Users<\/strong>: Once logged into a SQL Server instance, a login may need to access a specific database. For that, the login must be mapped to a user in that database.<\/li>\n\n\n\n<li><strong>Roles<\/strong>: Roles are like groups, and are used to manage permissions broadly across multiple users. Roles can exist at the server level or the database level. Roles can be granted permissions and users can be added to roles to inherit those permissions.<\/li>\n\n\n\n<li><strong>Schemas<\/strong>: Schemas are containers within a database that contain database objects. Users can be given permissions to schemas, granting them permissions to all objects within that schema.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-manage-the-server-logins\"><span class=\"ez-toc-section\" id=\"2-manage-the-server-logins\"><\/span>2. Manage the Server Logins<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To create a login, use the <code>CREATE LOGIN<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE LOGIN MyLogin\nWITH PASSWORD = 'MyStrongPassword123';\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-manage-the-database-users\"><span class=\"ez-toc-section\" id=\"3-manage-the-database-users\"><\/span>3. Manage the Database Users<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To create a database user for the new login, use the <code>CREATE USER<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE MyDatabase;\nCREATE USER MyUser\nFOR LOGIN MyLogin;\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-assign-specific-object-level-permissions\"><span class=\"ez-toc-section\" id=\"4-assign-specific-object-level-permissions\"><\/span>4. Assign specific Object level permissions<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Object-level permissions in SQL Server allow you to grant, deny, or revoke permissions on specific database objects, such as tables, views, or stored procedures. This fine-grained control allows you to specify exactly what actions a user or role can take on an individual object.<\/p>\n\n\n\n<p>For instance, if you wanted to grant SELECT, INSERT, and UPDATE permissions to a user <code>MyUser<\/code> on a specific table <code>MyTable<\/code> in your database, you could use the following commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE MyDatabase;\nGRANT SELECT, INSERT, UPDATE ON MyTable TO MyUser;\n<\/pre>\n\n\n\n<p>Likewise, if you wanted to revoke these permissions later, you could use the REVOKE command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE MyDatabase;\nREVOKE SELECT, INSERT, UPDATE ON MyTable FROM MyUser;\n<\/pre>\n\n\n\n<p>Object-level permissions allow for granular security control within your SQL Server database, ensuring that users and roles have exactly the permissions they need, no more and no less. This can be an essential part of the principle of least privilege in database security.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-5-manage-roles\"><span class=\"ez-toc-section\" id=\"5-manage-roles\"><\/span>5. Manage Roles<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To create a role and assign permissions, use the <code>CREATE ROLE<\/code> and <code>GRANT<\/code> commands:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">USE MyDatabase;\n\nCREATE ROLE MyRole;\n\nGRANT SELECT, INSERT, UPDATE, DELETE\nON SCHEMA::dbo\nTO MyRole;\n<\/pre>\n\n\n\n<p>To add a user to a role, use the <code>ALTER ROLE<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ALTER ROLE MyRole\nADD MEMBER MyUser;\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-6-manage-sql-server-schemas\"><span class=\"ez-toc-section\" id=\"6-manage-sql-server-schemas\"><\/span>6. Manage SQL Server Schemas<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To create a schema and assign it to a user, use the <code>CREATE SCHEMA<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CREATE SCHEMA MySchema AUTHORIZATION MyUser;\n<\/pre>\n\n\n\n<p>To grant permissions on a schema, use the <code>GRANT<\/code> command:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">GRANT SELECT, INSERT, UPDATE, DELETE ON SCHEMA::MySchema TO MyUser;\n<\/pre>\n\n\n\n<p>Please remember to replace <code>MyLogin<\/code>, <code>MyStrongPassword123<\/code>, <code>MyDatabase<\/code>, <code>MyUser<\/code>, <code>MyRole<\/code>, and <code>MySchema<\/code> with your own names\/passwords. It&#8217;s important to remember that managing security is more than just these few commands. You should always follow the principle of least privilege, granting only the permissions that are needed for each user or role.<\/p>\n\n\n\n<p>Also, make sure you protect sensitive data, use strong passwords, and keep your SQL Server up to date to protect against known vulnerabilities. Regularly reviewing and auditing your security settings is also a key part of maintaining a secure environment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-conclusion-about-the-sql-server-security-overview\">Conclusion about the SQL Server security overview<\/h3>\n\n\n\n<p>To manage security effectively in SQL Server, it&#8217;s important to understand and properly <strong><em>implement several key concepts<\/em><\/strong>:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create server logins and database users<\/strong>: Establish identities for access control, keeping in mind the principle of least privilege to limit potential vulnerabilities.<\/li>\n\n\n\n<li><strong>Define roles and assign permissions<\/strong>: Group users into roles for easier management of permissions, again being careful to grant only necessary permissions.<\/li>\n\n\n\n<li><strong>Use schemas for organization and access control<\/strong>: Manage access at a broad level by assigning permissions to entire schemas, while maintaining the flexibility to adjust permissions at the object level if needed.<\/li>\n\n\n\n<li><strong>Manage object-level permissions<\/strong>: Implement fine-grained control over specific database objects when necessary to ensure precise access control.<\/li>\n\n\n\n<li><strong>Regularly review and audit<\/strong>: Keep your security settings up to date, review them regularly, and conduct audits to identify potential security issues before they become problems.<\/li>\n<\/ol>\n\n\n\n<p>By understanding and applying these concepts, you can create a robust and secure SQL Server environment that protects your data while supporting the needs of your users and applications. Remember, security is an ongoing process that requires regular attention and adjustment as your environment and requirements evolve.<\/p>\n\n\n\n<p>To go further, let0s see <a href=\"https:\/\/expert-only.com\/en\/dba\/create-a-sql-server-database-with-a-script\/\">how to create an MS SQL database using scripts<\/a> or <a href=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/\">using the GUI in SSMS<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-wp-embed is-provider-sql-and-it-tutorials wp-block-embed-sql-and-it-tutorials\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"dpPFjQuQIM\"><a href=\"https:\/\/expert-only.com\/en\/dba\/create-a-sql-server-database-with-a-script\/\">Create a SQL Server database with a script<\/a><\/blockquote><iframe loading=\"lazy\" class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Create a SQL Server database with a script&#8221; &#8212; SQL and IT Tutorials\" src=\"https:\/\/expert-only.com\/en\/dba\/create-a-sql-server-database-with-a-script\/embed\/#?secret=Asc7RiaXTo#?secret=dpPFjQuQIM\" data-secret=\"dpPFjQuQIM\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe>\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>In any database system, is of utmost importance to properly manage SQL Server security. It is the cornerstone of protecting sensitive data and ensuring that only authorized personnel can access and modify it. In the context of SQL Server <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\" title=\"How to manage SQL Server security with scripts?\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10834,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[488],"tags":[],"class_list":{"0":"post-26497","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dba"},"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.7 (Yoast SEO v26.2) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to manage SQL Server security with scripts? DBA<\/title>\n<meta name=\"description\" content=\"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to manage SQL Server security with scripts?\" \/>\n<meta property=\"og:description\" content=\"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL and IT Tutorials\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-07T03:07:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-08T15:08:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1920\" \/>\n\t<meta property=\"og:image:height\" content=\"1080\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Expert-Only\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@expert_only\" \/>\n<meta name=\"twitter:site\" content=\"@expert_only\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Expert-Only\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"How to manage SQL Server security with scripts?\",\"datePublished\":\"2023-06-07T03:07:00+00:00\",\"dateModified\":\"2023-08-08T15:08:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\"},\"wordCount\":821,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg\",\"articleSection\":[\"SQL Server DBA\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\",\"url\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\",\"name\":\"How to manage SQL Server security with scripts? DBA\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg\",\"datePublished\":\"2023-06-07T03:07:00+00:00\",\"dateModified\":\"2023-08-08T15:08:11+00:00\",\"description\":\"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to manage SQL Server security with scripts?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/expert-only.com\/en\/#website\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"name\":\"SQL and IT Tutorials\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/expert-only.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/expert-only.com\/en\/#organization\",\"name\":\"Expert-Only\",\"url\":\"https:\/\/expert-only.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg\",\"width\":381,\"height\":174,\"caption\":\"Expert-Only\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ExpertOnlyCom\/\",\"https:\/\/x.com\/expert_only\",\"https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\",\"name\":\"Expert-Only\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g\",\"caption\":\"Expert-Only\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to manage SQL Server security with scripts? DBA","description":"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/","og_locale":"en_US","og_type":"article","og_title":"How to manage SQL Server security with scripts?","og_description":"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.","og_url":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-06-07T03:07:00+00:00","article_modified_time":"2023-08-08T15:08:11+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg","type":"image\/jpeg"}],"author":"Expert-Only","twitter_card":"summary_large_image","twitter_creator":"@expert_only","twitter_site":"@expert_only","twitter_misc":{"Written by":"Expert-Only","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"How to manage SQL Server security with scripts?","datePublished":"2023-06-07T03:07:00+00:00","dateModified":"2023-08-08T15:08:11+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/"},"wordCount":821,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg","articleSection":["SQL Server DBA"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/","url":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/","name":"How to manage SQL Server security with scripts? DBA","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg","datePublished":"2023-06-07T03:07:00+00:00","dateModified":"2023-08-08T15:08:11+00:00","description":"Tutorial to manage SQL Server security, covering server logins, users, roles, schemas, and permissions with practical script examples.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/problem-1951987_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/dba\/manage-sql-server-security\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"How to manage SQL Server security with scripts?"}]},{"@type":"WebSite","@id":"https:\/\/expert-only.com\/en\/#website","url":"https:\/\/expert-only.com\/en\/","name":"SQL and IT Tutorials","description":"","publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/expert-only.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/expert-only.com\/en\/#organization","name":"Expert-Only","url":"https:\/\/expert-only.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2017\/09\/cropped-logo_Expert-Only.jpg","width":381,"height":174,"caption":"Expert-Only"},"image":{"@id":"https:\/\/expert-only.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ExpertOnlyCom\/","https:\/\/x.com\/expert_only","https:\/\/www.youtube.com\/channel\/UCMS5sR_FwAetB0FmciNvUaA"]},{"@type":"Person","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef","name":"Expert-Only","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/084b15660763ff5b13bb60b2f52f97bb?s=96&d=identicon&r=g","caption":"Expert-Only"}}]}},"_links":{"self":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26497","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/comments?post=26497"}],"version-history":[{"count":0,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26497\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10834"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=26497"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=26497"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=26497"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}