{"id":26545,"date":"2023-06-13T06:37:00","date_gmt":"2023-06-13T04:37:00","guid":{"rendered":"https:\/\/expert-only.com\/?p=26545"},"modified":"2023-08-13T15:01:39","modified_gmt":"2023-08-13T13:01:39","slug":"sql-server-sqlcmd","status":"publish","type":"post","link":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/","title":{"rendered":"SQLCMD examples to use SQL Server in command line"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\" id=\"h-practical-guide-on-how-to-use-the-sql-server-sqlcmd-tool\"><strong><em>Practical guide on how to use the SQL Server SQLCMD tool.<\/em><\/strong><\/h4>\n\n\n\n<p>The tutorial about the SQLCMD examples is divided into different sections, providing a wide overview of various functionalities, use cases, and handy tips with the command line tool. It includes practical code examples to enhance understanding and automate daily DBA tasks.<\/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\/t-sql\/sql-server-sqlcmd\/#1-introduction-to-the-sql-server-sqlcmd-tool\" >1. Introduction to the SQL Server SQLCMD tool<\/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\/t-sql\/sql-server-sqlcmd\/#2-installation-and-configuration-of-sqlcmd\" >2. Installation and Configuration of SQLCMD<\/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\/t-sql\/sql-server-sqlcmd\/#3-sqlcmd-examples-with-basic-commands\" >3. SQLCMD examples with basic commands<\/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\/t-sql\/sql-server-sqlcmd\/#4-sql-server-sqlcmd-advanced-use-cases\" >4. SQL Server SQLCMD Advanced Use Cases<\/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\/t-sql\/sql-server-sqlcmd\/#5-sqlcmd-tips-and-best-practices\" >5. SQLCMD Tips and Best Practices<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-1-introduction-to-the-sql-server-sqlcmd-tool\"><span class=\"ez-toc-section\" id=\"1-introduction-to-the-sql-server-sqlcmd-tool\"><\/span>1. Introduction to the SQL Server SQLCMD tool<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>SQLCMD is a command-line tool that allows you to interact with SQL Server efficiently. With the SQL Server SQLCMD tool, you can run <a href=\"https:\/\/expert-only.com\/en\/t-sql\/t-sql-transactions\/\"><strong>Transact-SQL commands<\/strong><\/a>, system procedures, and SQL scripts. This invaluable tool provides a bridge between the user and SQL Server, allowing for direct communication and manipulation of <a href=\"https:\/\/expert-only.com\/en\/dba\/create-sql-server-database-with-ssms\/\"><strong>databases<\/strong><\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1.1 Why use the SQL Server SQLCMD command line tool?<\/h3>\n\n\n\n<p>SQLCMD is not just a tool but a powerful asset in the hands of database administrators and developers. Through its streamlined interface, it brings the following advantages:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Ease of Access<\/strong>: SQLCMD makes it simple to run and manage SQL queries directly from the command line.<\/li>\n\n\n\n<li><strong>Automation Capability<\/strong>: You can script complex procedures, enabling a smooth workflow and reducing the room for error.<\/li>\n\n\n\n<li><strong>Integration with Other Tools<\/strong>: It seamlessly integrates with various other SQL Server tools, enhancing functionality and efficiency.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">1.2 How SQLCMD Works ?<\/h3>\n\n\n\n<p>The MS SQL command-line utility works as an interface to SQL Server. By accepting commands in Transact-SQL (T-SQL), it translates human-readable queries into actions that the SQL Server can perform. This includes executing commands, retrieving data, and even managing entire databases. The convenience, flexibility, and power of the SQLCMD tool make it an essential resource for anyone working with Microsoft SQL.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-2-installation-and-configuration-of-sqlcmd\"><span class=\"ez-toc-section\" id=\"2-installation-and-configuration-of-sqlcmd\"><\/span>2. Installation and Configuration of SQLCMD<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To embark on the journey of using <strong><em>SQLCMD<\/em><\/strong>, a couple of initial steps need to be undertaken. First and foremost, the installation of SQLCMD must be accomplished on your operating system. It&#8217;s a fairly straightforward process that can be executed by following the specific instructions provided for your OS version: <strong><em>Windows or Linux<\/em><\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-2-1-difference-between-the-windows-and-the-linux-configurations\">2.1 Difference between the Windows and the Linux configurations<\/h3>\n\n\n\n<p>The installation and configuration of SQLCMD vary between Windows and Linux. On Windows, SQLCMD can be installed as a part of the SQL Server Management Studio (SSMS) and is typically configured using a GUI interface. Commands can be run from the Command Prompt.<\/p>\n\n\n\n<p>In contrast, Linux requires manual installation of the <code>mssql-tools<\/code> package and uses a terminal interface for configuration.<\/p>\n\n\n\n<p>The command-line syntax may differ slightly between the two, such as the path conventions and scripting nuances. Despite these differences, both provide a powerful command-line tool for managing SQL Server instances.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-2-2-installing-sqlcmd-on-windows-or-linux\">2.2 Installing SQLCMD on Windows or Linux<\/h4>\n\n\n\n<p>The commands are the same for both Windows and <a href=\"https:\/\/documentation.suse.com\/sbp\/all\/single-html\/TRD-sql-server-getting-started\/\" target=\"_blank\" rel=\"noreferrer noopener\">Linux<\/a>, as SQL Server&#8217;s command-line tools are designed to work consistently across different platforms.<\/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=\"\"># Windows\nsqlcmd -S localhost -U sa -P password\n\n# Linux\nsqlcmd -S localhost -U sa -P password\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-3-sqlcmd-examples-with-basic-commands\"><span class=\"ez-toc-section\" id=\"3-sqlcmd-examples-with-basic-commands\"><\/span>3. SQLCMD examples with basic commands<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let&#8217;s dive into some basic commands to get familiar with the SQL Server SQLCMD tool.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-1-connecting-to-a-database\">3.1 Connecting to a Database<\/h3>\n\n\n\n<p>To connect to a specific database, use the following 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=\"\">sqlcmd -S server_name -d database_name -U username -P password\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-3-2-sql-cmd-examples-with-queries\">3.2 SQL CMD examples with queries<\/h3>\n\n\n\n<p>With SQLCMD, you can easily run SQL queries directly from the command line. Here&#8217;s an example:<\/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=\"\">sqlcmd -Q \"SELECT * FROM Users\"\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-4-sql-server-sqlcmd-advanced-use-cases\"><span class=\"ez-toc-section\" id=\"4-sql-server-sqlcmd-advanced-use-cases\"><\/span>4. SQL Server SQLCMD Advanced Use Cases<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>SQLCMD is not just limited to basic queries. It provides several advanced functionalities.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-4-1-using-variables-with-sql-server-sqlcmd\">4.1 Using Variables with SQL Server SQLCMD<\/h3>\n\n\n\n<p>You can use variables within your SQL scripts. Here&#8217;s an example:<\/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=\"\">sqlcmd -v var_name=\"value\" -Q \"SELECT * FROM Table WHERE Column = @var_name\"\n<\/pre>\n\n\n\n<p>SQLCMD provides a robust interface to interact with SQL Server, allowing for various advanced use cases. Below are some of them.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4.2 SQL CMD example to Query Multiple Databases<\/h3>\n\n\n\n<p>You can use SQLCMD to execute queries across multiple databases on the same server.<\/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=\"\">sqlcmd -S localhost -U sa -P password -d Database1 -Q \"SELECT * FROM Table1; USE Database2; SELECT * FROM Table2;\"\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.3 Running Scripts from Files<\/h3>\n\n\n\n<p>You can run a SQL script from a file using the <code>-i<\/code> option.<\/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=\"\">sqlcmd -S localhost -U sa -P password -i MyScript.sql\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.4 Outputting Query Results to a File<\/h3>\n\n\n\n<p>Redirect the output of your queries to a text file using the <code>-o<\/code> option.<\/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=\"\">sqlcmd -S localhost -U sa -P password -Q \"SELECT * FROM MyTable;\" -o output.txt\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.5 Connecting to a Named Instance<\/h3>\n\n\n\n<p>If you&#8217;re working with a named instance of SQL Server, specify it using the <code>-S<\/code> option.<\/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=\"\">sqlcmd -S localhost\\InstanceName -U sa -P password\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.6 Utilizing Windows Authentication<\/h3>\n\n\n\n<p>You can connect to SQL Server using Windows Authentication by omitting the username and password.<\/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=\"\">sqlcmd -S localhost -E\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.7 Executing Commands with Variables<\/h3>\n\n\n\n<p>SQLCMD allows the use of variables within your scripts. You can declare and use them with the <code>:SETVAR<\/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=\"\">sqlcmd -S localhost -U sa -P password -Q \"EXEC sp_databases; :SETVAR MyVariable 'MyValue'; PRINT '$(MyVariable)';\"\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.8 Implementing Transaction Control<\/h3>\n\n\n\n<p>You can manage transactions within your SQLCMD sessions by using the standard T-SQL transaction control statements like <code>BEGIN TRANSACTION<\/code>, <code>COMMIT<\/code>, and <code>ROLLBACK<\/code>.<\/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=\"\">sqlcmd -S localhost -U sa -P password -Q \"BEGIN TRANSACTION; UPDATE Table1 SET Column1 = 'value' WHERE Column2 = 'condition'; COMMIT;\"\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4.9 Generate XML Output using the SQLCMD tool<\/h3>\n\n\n\n<p>You can generate XML output from a query by using the <code>-y<\/code> or <code>-Y<\/code> options with the <code>-r<\/code> option.<\/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=\"\">sqlcmd -S localhost -U sa -P password -Q \"SELECT * FROM MyTable FOR XML AUTO;\" -r 1 -o output.xml\n<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-5-sqlcmd-tips-and-best-practices\"><span class=\"ez-toc-section\" id=\"5-sqlcmd-tips-and-best-practices\"><\/span>5. SQLCMD Tips and Best Practices<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To make the most of SQLCMD, follow these best practices:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Always close connections when not in use.<\/li>\n\n\n\n<li>Use the <code>-b<\/code> switch to halt execution on errors.<\/li>\n\n\n\n<li>Optimize scripts by <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/tools\/sqlcmd-utility\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">using parameters<\/a>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-conclusion-on-sqlcmd-examples\">Conclusion on SQLCMD examples<\/h3>\n\n\n\n<p>The SQLCMD examples offers an array of possibilities to manage SQL Server from the <strong><a href=\"https:\/\/expert-only.com\/en\/ms-dos\/copy-windows-files-with-cmd\/\">Windows command line<\/a><\/strong>. Explore different use cases, and don&#8217;t hesitate to delve into more complex operations.<\/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\">\nhttps:\/\/expert-only.com\/en\/ms-dos\/copy-windows-files-with-cmd\/\n<\/div><\/figure>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Practical guide on how to use the SQL Server SQLCMD tool. The tutorial about the SQLCMD examples is divided into different sections, providing a wide overview of various functionalities, use cases, and handy tips with the command line tool. <a class=\"mh-excerpt-more\" href=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\" title=\"SQLCMD examples to use SQL Server in command line\">&#8230;<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":10864,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[454],"tags":[],"class_list":{"0":"post-26545","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-t-sql"},"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>SQLCMD examples (command line tool) - T-SQL<\/title>\n<meta name=\"description\" content=\"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.\" \/>\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\/t-sql\/sql-server-sqlcmd\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SQLCMD examples to use SQL Server in command line\" \/>\n<meta property=\"og:description\" content=\"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\" \/>\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-13T04:37:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-08-13T13:01:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_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\/t-sql\/sql-server-sqlcmd\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\"},\"author\":{\"name\":\"Expert-Only\",\"@id\":\"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef\"},\"headline\":\"SQLCMD examples to use SQL Server in command line\",\"datePublished\":\"2023-06-13T04:37:00+00:00\",\"dateModified\":\"2023-08-13T13:01:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\"},\"wordCount\":809,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/expert-only.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg\",\"articleSection\":[\"T-SQL\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\",\"url\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\",\"name\":\"SQLCMD examples (command line tool) - T-SQL\",\"isPartOf\":{\"@id\":\"https:\/\/expert-only.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg\",\"datePublished\":\"2023-06-13T04:37:00+00:00\",\"dateModified\":\"2023-08-13T13:01:39+00:00\",\"description\":\"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.\",\"breadcrumb\":{\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage\",\"url\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg\",\"contentUrl\":\"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg\",\"width\":1920,\"height\":1080},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"en\",\"item\":\"https:\/\/expert-only.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SQLCMD examples to use SQL Server in command line\"}]},{\"@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":"SQLCMD examples (command line tool) - T-SQL","description":"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.","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\/t-sql\/sql-server-sqlcmd\/","og_locale":"en_US","og_type":"article","og_title":"SQLCMD examples to use SQL Server in command line","og_description":"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.","og_url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/","og_site_name":"SQL and IT Tutorials","article_publisher":"https:\/\/www.facebook.com\/ExpertOnlyCom\/","article_published_time":"2023-06-13T04:37:00+00:00","article_modified_time":"2023-08-13T13:01:39+00:00","og_image":[{"width":1920,"height":1080,"url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_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\/t-sql\/sql-server-sqlcmd\/#article","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/"},"author":{"name":"Expert-Only","@id":"https:\/\/expert-only.com\/en\/#\/schema\/person\/406a9576b52944f018739a42046873ef"},"headline":"SQLCMD examples to use SQL Server in command line","datePublished":"2023-06-13T04:37:00+00:00","dateModified":"2023-08-13T13:01:39+00:00","mainEntityOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/"},"wordCount":809,"commentCount":0,"publisher":{"@id":"https:\/\/expert-only.com\/en\/#organization"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg","articleSection":["T-SQL"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/","url":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/","name":"SQLCMD examples (command line tool) - T-SQL","isPartOf":{"@id":"https:\/\/expert-only.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage"},"image":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage"},"thumbnailUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg","datePublished":"2023-06-13T04:37:00+00:00","dateModified":"2023-08-13T13:01:39+00:00","description":"Dive into these SQLCMD examples tool with a tutorial using practical code examples and use cases to master SQL Server in command line.","breadcrumb":{"@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#primaryimage","url":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg","contentUrl":"https:\/\/expert-only.com\/wp-content\/uploads\/2022\/09\/texture-design-7E25D084595_1920x1080.jpg","width":1920,"height":1080},{"@type":"BreadcrumbList","@id":"https:\/\/expert-only.com\/en\/t-sql\/sql-server-sqlcmd\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"en","item":"https:\/\/expert-only.com\/en\/"},{"@type":"ListItem","position":2,"name":"SQLCMD examples to use SQL Server in command line"}]},{"@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\/26545","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=26545"}],"version-history":[{"count":10,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26545\/revisions"}],"predecessor-version":[{"id":26561,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/posts\/26545\/revisions\/26561"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media\/10864"}],"wp:attachment":[{"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/media?parent=26545"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/categories?post=26545"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/expert-only.com\/en\/wp-json\/wp\/v2\/tags?post=26545"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}