{"id":78,"date":"2018-03-27T21:17:42","date_gmt":"2018-03-27T14:17:42","guid":{"rendered":"http:\/\/www.sqlservertutorial.net\/?page_id=78"},"modified":"2024-09-30T10:56:22","modified_gmt":"2024-09-30T03:56:22","slug":"connect-to-the-sql-server","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/","title":{"rendered":"Connect to the SQL Server"},"content":{"rendered":"\n<p><strong>Summary<\/strong>: in this tutorial, you will learn how to connect to SQL Server from the SQL Server Management Studio and execute a&nbsp;query.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id='connect-to-the-sql-server-using-ssms'>Connect to the SQL Server using SSMS <a href=\"#connect-to-the-sql-server-using-ssms\" class=\"anchor\" id=\"connect-to-the-sql-server-using-ssms\" title=\"Anchor for Connect to the SQL Server using SSMS\">#<\/a><\/h2>\n\n\n\n<p>To connect to the SQL Server using the Microsoft SQL Server Management Studio, follow these steps:<\/p>\n\n\n\n<p>Step 1. Launch the Microsoft SQL Server Management Studio:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"476\" height=\"285\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png\" alt=\"\" class=\"wp-image-2854\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png 476w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server-300x180.png 300w\" sizes=\"auto, (max-width: 476px) 100vw, 476px\" \/><\/figure>\n\n\n\n<p>Step 2. Choose the <strong>Database Engine<\/strong>&#8230;<strong>\u00a0<\/strong> from the <strong>Connect<\/strong> menu under the <strong>Object Explorer<\/strong>:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"213\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Open-the-Connection-Dialog-300x213.png\" alt=\"\" class=\"wp-image-71\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Open-the-Connection-Dialog-300x213.png 300w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Open-the-Connection-Dialog.png 368w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/figure>\n\n\n\n<p>Step 3. Enter the following information:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Server Type: <strong>Database Engine<\/strong><\/li>\n\n\n\n<li>Server name: <strong>localhost<\/strong><\/li>\n\n\n\n<li>Authentication: <strong>SQL Server Authentication<\/strong><\/li>\n\n\n\n<li>Login: <strong>sa<\/strong><\/li>\n\n\n\n<li>Password: (The one you entered during the <a href=\"https:\/\/www.sqlservertutorial.net\/install-sql-server\/\">installation<\/a>.)<\/li>\n\n\n\n<li>Check the <strong>Remember Password<\/strong>. <\/li>\n\n\n\n<li>Encryption: <strong>Optional<\/strong> <\/li>\n<\/ol>\n\n\n\n<p>Click the <strong>Connect<\/strong> button to connect to the SQL Server:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"477\" height=\"524\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-to-Local-Server-Server.png\" alt=\"Connect to Local Server Server\" class=\"wp-image-4612\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-to-Local-Server-Server.png 477w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-to-Local-Server-Server-273x300.png 273w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/figure>\n\n\n\n<p class=\"note\">If the connection is successful, you will see the following <strong>Object Explorer<\/strong> panel:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"497\" height=\"402\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-Microsoft-SQL-Server-Management-Studio.png\" alt=\"Connect Microsoft SQL Server Management Studio\" class=\"wp-image-4613\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-Microsoft-SQL-Server-Management-Studio.png 497w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/Connect-Microsoft-SQL-Server-Management-Studio-300x243.png 300w\" sizes=\"auto, (max-width: 497px) 100vw, 497px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id='execute-a-query'>Execute a query <a href=\"#execute-a-query\" class=\"anchor\" id=\"execute-a-query\" title=\"Anchor for Execute a query\">#<\/a><\/h2>\n\n\n\n<p>To execute a query you follow these steps:<\/p>\n\n\n\n<p>First, right-click on the <strong>localhost (SQL Server &#8230;)<\/strong> node and choose the <strong>New Query<\/strong> menu item:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"338\" height=\"301\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/New-Query.png\" alt=\"\" class=\"wp-image-70\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/New-Query.png 338w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/New-Query-300x267.png 300w\" sizes=\"auto, (max-width: 338px) 100vw, 338px\" \/><\/figure>\n\n\n\n<p>Second, enter the following query in the Editor<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"SQL (Structured Query Language)\" data-shcb-language-slug=\"sql\"><span><code class=\"hljs language-sql\"><span class=\"hljs-keyword\">select<\/span> @@<span class=\"hljs-keyword\">version<\/span>;<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">SQL (Structured Query Language)<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">sql<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>This query returns the version of the SQL Server.<\/p>\n\n\n\n<p>Third, click the <strong>Execute<\/strong> button:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"459\" height=\"271\" src=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-Execute-a-Query.png\" alt=\"\" class=\"wp-image-4614\" srcset=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-Execute-a-Query.png 459w, https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-Execute-a-Query-300x177.png 300w\" sizes=\"auto, (max-width: 459px) 100vw, 459px\" \/><\/figure>\n\n\n\n<p>The <strong>Results<\/strong> window shows the version of the SQL Server as shown in the above screenshot. A quick way to execute a query is to press the <strong>F5<\/strong> keyboard shortcut.<\/p>\n\n\n\n<p>Now, you should know how to connect to an SQL Server and execute a query from the SSMS.<\/p>\n<div class=\"helpful-block-content\" data-title=\"\">\n\t<header>\n\t\t<div class=\"wth-question\">Was this tutorial helpful?<\/div>\n\t\t<div class=\"wth-thumbs\">\n\t\t\t<button\n\t\t\t\tdata-post=\"78\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/\"\n\t\t\t\tdata-post-title=\"Connect to the SQL Server\"\n\t\t\t\tdata-response=\"1\"\n\t\t\t\tclass=\"wth-btn-rounded wth-yes-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t\tclass=\"feather feather-thumbs-up block w-full h-full\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M14 9V5a3 3 0 0 0-3-3l-4 9v11h11.28a2 2 0 0 0 2-1.7l1.38-9a2 2 0 0 0-2-2.3zM7 22H4a2 2 0 0 1-2-2v-7a2 2 0 0 1 2-2h3\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> Yes <\/span>\n\t\t\t<\/button>\n\n\t\t\t<button\n\t\t\t\tdata-response=\"0\"\n\t\t\t\tdata-post=\"78\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/\"\n\t\t\t\tdata-post-title=\"Connect to the SQL Server\"\n\t\t\t\tclass=\"wth-btn-rounded wth-no-btn\"\n\t\t\t>\n\t\t\t\t<svg\n\t\t\t\t\txmlns=\"http:\/\/www.w3.org\/2000\/svg\"\n\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\tstroke-width=\"2\"\n\t\t\t\t\tstroke-linecap=\"round\"\n\t\t\t\t\tstroke-linejoin=\"round\"\n\t\t\t\t>\n\t\t\t\t\t<path\n\t\t\t\t\t\td=\"M10 15v4a3 3 0 0 0 3 3l4-9V2H5.72a2 2 0 0 0-2 1.7l-1.38 9a2 2 0 0 0 2 2.3zm7-13h2.67A2.31 2.31 0 0 1 22 4v7a2.31 2.31 0 0 1-2.33 2H17\"\n\t\t\t\t\t><\/path>\n\t\t\t\t<\/svg>\n\t\t\t\t<span class=\"sr-only\"> No <\/span>\n\t\t\t<\/button>\n\t\t<\/div>\n\t<\/header>\n\n\t<div class=\"wth-form hidden\">\n\t\t<div class=\"wth-form-wrapper\">\n\t\t\t<div class=\"wth-title\"><\/div>\n\t\t\t\n\t\t\t<textarea class=\"wth-message\"><\/textarea>\n\n\t\t\t<button class=\"btn btn-primary wth-btn-submit\">Send<\/button>\n\t\t\t<button class=\"btn wth-btn-cancel\">Cancel<\/button>\n\t\t\n\t\t<\/div>\n\t<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you will learn how to connect to SQL Server from the SQL Server Management Studio and execute a\u00a0query.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":394,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-78","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Connect to a SQL Server from SSMS<\/title>\n<meta name=\"description\" content=\"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Connect to a SQL Server from SSMS\" \/>\n<meta property=\"og:description\" content=\"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-30T03:56:22+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/\",\"name\":\"Connect to a SQL Server from SSMS\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SSMS-connect-to-SQL-Server.png\",\"datePublished\":\"2018-03-27T14:17:42+00:00\",\"dateModified\":\"2024-09-30T03:56:22+00:00\",\"description\":\"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SSMS-connect-to-SQL-Server.png\",\"contentUrl\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/wp-content\\\/uploads\\\/SSMS-connect-to-SQL-Server.png\",\"width\":476,\"height\":285},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/connect-to-the-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting Started with SQL Server\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/getting-started\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Connect to the SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\",\"name\":\"SQL Server Tutorial\",\"description\":\"The Practical SQL Server Tutorial\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Connect to a SQL Server from SSMS","description":"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.","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:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Connect to a SQL Server from SSMS","og_description":"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.","og_url":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-09-30T03:56:22+00:00","og_image":[{"url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/","url":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/","name":"Connect to a SQL Server from SSMS","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png","datePublished":"2018-03-27T14:17:42+00:00","dateModified":"2024-09-30T03:56:22+00:00","description":"In this tutorial, you will learn how to connect to the SQL Server from the SQL Server Management Studio and execute a\u00a0query.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/#primaryimage","url":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png","contentUrl":"https:\/\/www.sqlservertutorial.net\/wp-content\/uploads\/SSMS-connect-to-SQL-Server.png","width":476,"height":285},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/getting-started\/connect-to-the-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"Getting Started with SQL Server","item":"https:\/\/www.sqlservertutorial.net\/getting-started\/"},{"@type":"ListItem","position":3,"name":"Connect to the SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/www.sqlservertutorial.net\/#website","url":"https:\/\/www.sqlservertutorial.net\/","name":"SQL Server Tutorial","description":"The Practical SQL Server Tutorial","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqlservertutorial.net\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":2,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/78\/revisions"}],"predecessor-version":[{"id":4615,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/78\/revisions\/4615"}],"up":[{"embeddable":true,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/394"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}