{"id":4520,"date":"2024-09-21T16:47:48","date_gmt":"2024-09-21T09:47:48","guid":{"rendered":"https:\/\/www.sqlservertutorial.net\/?page_id=4520"},"modified":"2024-09-24T09:46:40","modified_gmt":"2024-09-24T02:46:40","slug":"go-sql-server","status":"publish","type":"page","link":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/","title":{"rendered":"Go SQL Server"},"content":{"rendered":"\n<p>This tutorial series shows how to interact with the SQL Server from Go (or Golang) using the official Microsoft SQL Server Driver for Go.<\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='getting-started'>Section 1. Getting Started <a href=\"#getting-started\" class=\"anchor\" id=\"getting-started\" title=\"Anchor for Section 1. Getting Started\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.sqlservertutorial.net\/go-sql-server\/go-connect-sql-server\/\">Connecting to the SQL Server from Go<\/a> &#8211; Show you how to connect to an SQL Server database from a Go program.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='inserting-data'>Section 2. Inserting Data <a href=\"#inserting-data\" class=\"anchor\" id=\"inserting-data\" title=\"Anchor for Section 2. Inserting Data\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.sqlservertutorial.net\/go-sql-server\/go-sql-server-insert\/\">Inserting data into a table<\/a> &#8211; Insert a new row into a table and return the inserted ID from a Go program.<\/li>\n\n\n\n<li>Inserting multiple rows into a table &#8211; Insert multiple rows from a Go program using a multi-insert statement.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='querying-data'>Section 3. Querying Data <a href=\"#querying-data\" class=\"anchor\" id=\"querying-data\" title=\"Anchor for Section 3. Querying Data\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Select data from a table &#8211; Select one or more rows from a table in a Go program.<\/li>\n\n\n\n<li>Pagination &#8211; Paginate rows by breaking up a large result set into smaller ones.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='updating-data'>Section 4. Updating Data <a href=\"#updating-data\" class=\"anchor\" id=\"updating-data\" title=\"Anchor for Section 4. Updating Data\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Update data from a table &#8211; Update data in a table from a Go program.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='deleting-data'>Section 5. Deleting Data <a href=\"#deleting-data\" class=\"anchor\" id=\"deleting-data\" title=\"Anchor for Section 5. Deleting Data\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Delete data from a table &#8211; Delete data from a table in SQL Server from Go.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='performing-transactions'>Section 6. Performing Transactions <a href=\"#performing-transactions\" class=\"anchor\" id=\"performing-transactions\" title=\"Anchor for Section 6. Performing Transactions\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Perform a transaction &#8211; Perform an SQL Server transaction from Go.<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-constrained wp-block-group-is-layout-constrained\">\n<h2 class=\"wp-block-heading\" id='calling-stored-procedures'>Section 7. Calling Stored Procedures <a href=\"#calling-stored-procedures\" class=\"anchor\" id=\"calling-stored-procedures\" title=\"Anchor for Section 7. Calling Stored Procedures\">#<\/a><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Call a stored procedure &#8211; Call a stored procedure in SQL Server from Go.<\/li>\n\n\n\n<li>Call a stored procedure with OUTPUT parameters &#8211; Call a stored procedure with OUTPUT parameters from Go.<\/li>\n<\/ul>\n<\/div><\/div>\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=\"4520\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/go-sql-server\/\"\n\t\t\t\tdata-post-title=\"Go 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=\"4520\"\n\t\t\t\tdata-post-url=\"https:\/\/www.sqlservertutorial.net\/go-sql-server\/\"\n\t\t\t\tdata-post-title=\"Go 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>This tutorial series shows how to interact with the SQL Server from Go (or Golang) using the official Microsoft SQL Server Driver for Go. Section 1. Getting Started # Section 2. Inserting Data # Section 3. Querying Data # Section 4. Updating Data # Section 5. Deleting Data # Section 6. Performing Transactions # Section [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":23,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-4520","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>Golang SQL Server Tutorial<\/title>\n<meta name=\"description\" content=\"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.\" \/>\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\/go-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Golang SQL Server Tutorial\" \/>\n<meta property=\"og:description\" content=\"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqlservertutorial.net\/go-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"SQL Server Tutorial\" \/>\n<meta property=\"article:modified_time\" content=\"2024-09-24T02:46:40+00:00\" \/>\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=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/go-sql-server\\\/\",\"url\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/go-sql-server\\\/\",\"name\":\"Golang SQL Server Tutorial\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/#website\"},\"datePublished\":\"2024-09-21T09:47:48+00:00\",\"dateModified\":\"2024-09-24T02:46:40+00:00\",\"description\":\"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/go-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.sqlservertutorial.net\\\/go-sql-server\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/go-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.sqlservertutorial.net\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go 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":"Golang SQL Server Tutorial","description":"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.","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\/go-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Golang SQL Server Tutorial","og_description":"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.","og_url":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/","og_site_name":"SQL Server Tutorial","article_modified_time":"2024-09-24T02:46:40+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/","url":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/","name":"Golang SQL Server Tutorial","isPartOf":{"@id":"https:\/\/www.sqlservertutorial.net\/#website"},"datePublished":"2024-09-21T09:47:48+00:00","dateModified":"2024-09-24T02:46:40+00:00","description":"This tutorial series shows you how to use Go (Golang) to interact with the SQL Server.","breadcrumb":{"@id":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqlservertutorial.net\/go-sql-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqlservertutorial.net\/go-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqlservertutorial.net\/"},{"@type":"ListItem","position":2,"name":"Go 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\/4520","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=4520"}],"version-history":[{"count":5,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4520\/revisions"}],"predecessor-version":[{"id":4549,"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/pages\/4520\/revisions\/4549"}],"wp:attachment":[{"href":"https:\/\/www.sqlservertutorial.net\/wp-json\/wp\/v2\/media?parent=4520"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}