{"id":8239,"date":"2021-11-21T14:19:52","date_gmt":"2021-11-21T13:19:52","guid":{"rendered":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/?p=8239"},"modified":"2023-09-08T18:49:09","modified_gmt":"2023-09-08T16:49:09","slug":"the-best-way-to-query-sql-server","status":"publish","type":"post","link":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/","title":{"rendered":"The best method to Query SQL SERVER"},"content":{"rendered":"\n<p class=\"has-medium-font-size wp-block-paragraph\">The world of databases, today, is more and more in continuous expansion and their use is more and more intensive. Knowing how to <strong>Query SQL SERVER<\/strong> is essential for a developer, even more, to understand the logic and operation.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In this guide we will see how to write SQL Queries with Microsoft SQL Server and a specific SQL Server language, called T-SQL, which is the acronym for: &#8220;Transact SQL&#8221;.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Like SQL Server, all other database management systems also have an autonomous management language which, however, can differ from system to system. Anyway, in this guide I will explain the method to write SQL queries.<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">In questo articolo:<\/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:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#1_Install_Microsoft_SQL_SERVER_EXPRESS_2019\" >1. Install Microsoft SQL SERVER EXPRESS 2019<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#2_Install_SQL_SERVER_Management_Studio_SSMS\" >2. Install SQL SERVER Management Studio (SSMS)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#3_Create_Database_on_Microsoft_SQL_SERVER_EXPRESS_2019\" >3. Create Database on Microsoft SQL SERVER EXPRESS 2019<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#4_Create_Table_with_Microsoft_SQL_SERVER_EXPRESS_2019\" >4. Create Table with Microsoft SQL SERVER EXPRESS 2019<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#5_How_to_populate_tables_with_T-SQL\" >5. How to populate tables with T-SQL<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#6_The_best_way_to_Query_SQL_SERVER\" >6. The best way to Query SQL SERVER<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#61_The_aliases\" >6.1 The aliases<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#i\" >&nbsp;<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#62_Condition-based_processing_the_CASE_command\" >6.2 Condition-based processing; the CASE command<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#7_W3Schoolscom_the_interactive_online_portal_for_developers\" >7. W3Schools.com the interactive online portal for developers<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"1_Install_Microsoft_SQL_SERVER_EXPRESS_2019\"><\/span><strong>1. Install Microsoft SQL SERVER EXPRESS 2019<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">As a first step we need to install SQL Server Express 2019. SQL Server Express is a Microsoft tool that can be freely downloaded and used by anyone. However, this software has some limitations in the amount of data that can be managed, which as regards SQL SERVER, is more than enough to develop free small and medium-sized management software.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Just for the record, SQL SERVER EXPRESS can be installed not only on Windows operating systems but also on Linux distributions. <a href=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-downloads\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">At this address<\/a> it is possible to <a href=\"https:\/\/www.microsoft.com\/en-us\/sql-server\/sql-server-downloads\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">download SQL SERVER EXPRESS 2019 for Windows<\/a> operating systems.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Then click on \u201c<strong>Download Now<\/strong>\u201d and proceed with the download of the SQL Server Express 2019 version.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1629\" height=\"947\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1.jpg\" alt=\"query sql server\" class=\"wp-image-8246\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1.jpg 1629w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1-300x174.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1-774x450.jpg 774w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1-768x446.jpg 768w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-express-2019-1-1536x893.jpg 1536w\" sizes=\"auto, (max-width: 1629px) 100vw, 1629px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Once the software download phase is complete, all you have to do is proceed with the installation which, however simple, still concerns the installation of a server-type software that can also take place on your personal PC with a Windows 8 or Windows operating system. 10. That is, more modern desktop computers, you don&#8217;t need a server to install it on.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In this regard, in case you find it difficult during installation, I recommend that you follow this video tutorial to dispel any doubts about the settings and choices to be made during the procedure.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Install SQL Server Express 2019\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/LIytfaWH_10?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/youtu.be\/LIytfaWH_10\" target=\"_blank\" rel=\"noreferrer noopener\">Install SQL Server Express<\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">After the installation of SQL SERVER, restart the computer as required and all the services necessary for managing relational databases are active and ready for use. However, there is still a command console for SQL SERVER, that is, the software that will allow you to issue T-SQL commands to managed databases. In fact, in the next paragraph we will see how to install SQL SERVER Management Studio.<\/p>\n\n\n\n<hr>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">READ MORE: <a href=\"https:\/\/www.phpcodewizard.it\/index_en.html\" target=\"_blank\" rel=\"noreferrer noopener\">Do you want to manage your SQL databases without writing code?<\/a><\/p>\n\n\n\n<hr>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"2_Install_SQL_SERVER_Management_Studio_SSMS\"><\/span><strong>2. Install SQL SERVER Management Studio (SSMS)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Once the installation of SQL SERVER EXPRESS 2019 is finished, you must necessarily install another software. This software is <strong>SQL SERVER Management Studio<\/strong>. From here on we will refer to this tool with the acronym SSMS.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Then, <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/ssms\/download-sql-server-management-studio-ssms?view=sql-server-ver15\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">click on this link<\/a> and then on the item &#8220;<strong>Free Download for SQL Server Management Studio (SSMS) 18.10<\/strong>&#8220;. Wait for the download to complete and proceed with the installation of SSMS.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"879\" height=\"506\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-management-studio-1.jpg\" alt=\"download sql server 2019 management studio\" class=\"wp-image-8248\" style=\"object-fit:cover\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-management-studio-1.jpg 879w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-management-studio-1-300x173.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-management-studio-1-782x450.jpg 782w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/download-sql-server-management-studio-1-768x442.jpg 768w\" sizes=\"auto, (max-width: 879px) 100vw, 879px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Both for SQL SERVER EXPRESS 2019 and for SSMS the download could take up to several minutes, being very full-bodied applications. In any case, the download speed will depend solely and exclusively on the speed and quality of your internet connection.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In the video tutorial that follows, you can see step-by-step how to install SQL SERVER Management Studio and start writing your first SQL queries.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"How to Download and Install SSMS Sql Server Management Studio in 2021\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/59Aklwjjkao?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/youtu.be\/59Aklwjjkao\" target=\"_blank\" rel=\"noreferrer noopener\">Install SQL Server Management Studio<\/a><\/figcaption><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In reality there are also other tools to send commands to SQL SERVER databases, one of the most accredited, in addition to Microsoft&#8217;s SSMS, is <strong>Toad For SQL SERVER<\/strong>. This application, developed by <a href=\"https:\/\/www.quest.com\/toad\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Quest<\/a>, is an excellent tool widely used by developers all over the world to manage not only SQL SERVER databases, but also MYSQL, ORACLE, and many others.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1292\" height=\"721\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/toad-for-sql-server-1.jpg\" alt=\"download toad for sql server\" class=\"wp-image-8250\" style=\"object-fit:cover\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/toad-for-sql-server-1.jpg 1292w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/toad-for-sql-server-1-300x167.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/toad-for-sql-server-1-800x445.jpg 800w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/toad-for-sql-server-1-768x429.jpg 768w\" sizes=\"auto, (max-width: 1292px) 100vw, 1292px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Once the SSMS installation is complete, you need to start creating your first databases, a necessary step to be able to write an SQL Query. In the next paragraph we will see how to create a database with SSMS.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"3_Create_Database_on_Microsoft_SQL_SERVER_EXPRESS_2019\"><\/span><strong>3. Create Database on Microsoft SQL SERVER EXPRESS 2019<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">To create a new database with SSMS it is very simple, in fact, once you have started SSMS all you have to do is click with the right mouse button on the <strong>Databases<\/strong> item and then on <strong>New Database<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"355\" height=\"384\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-sql-server-1.jpg\" alt=\"create sql server database\" class=\"wp-image-8252\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-sql-server-1.jpg 355w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-sql-server-1-277x300.jpg 277w\" sizes=\"auto, (max-width: 355px) 100vw, 355px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, type in the <strong>Database Name<\/strong> field the name of the database you want to create, for this purpose I have chosen the <strong>test<\/strong> name. Now click on the <strong>OK<\/strong> button and your first database has been created.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"700\" height=\"630\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-prova-1.jpg\" alt=\"create database table\" class=\"wp-image-8254\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-prova-1.jpg 700w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-prova-1-300x270.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-database-prova-1-500x450.jpg 500w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Once you have created the test database you need to create another SQL SERVER object, I am talking about the <strong>table<\/strong> object. In fact, in the next paragraph we will see <strong>how to create a table within a database on SQL Server<\/strong>.<strong><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"4_Create_Table_with_Microsoft_SQL_SERVER_EXPRESS_2019\"><\/span><strong>4. Create Table with Microsoft SQL SERVER EXPRESS 2019<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">To create a table with SSMS is very simple, in fact, once you have created and identified the entry relating to the test database, you just have to click with the right mouse button on the <strong>test<\/strong> item under <strong>Databases<\/strong> and then on <strong>New Table<\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"340\" height=\"486\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-nuova-tabella-1.jpg\" alt=\"create new database table sql server\" class=\"wp-image-8255\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-nuova-tabella-1.jpg 340w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-nuova-tabella-1-210x300.jpg 210w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-nuova-tabella-1-315x450.jpg 315w\" sizes=\"auto, (max-width: 340px) 100vw, 340px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">The operation, however simple, is not yet completely complete. In fact, a table contains a structure, that is, a set of fields or columns necessary to contain the data that will populate the table from time to time.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">To achieve the purpose of this guide, we will only create two tables, one will be the <strong>anagrafica<\/strong> data table and the other we will call tax_codes. Therefore, the first will contain the fields id, surname and name, while the second will contain the fields id and code_fiscale. At this point, however, there is a clarification to be made, you will surely have noticed the presence of an <strong>id<\/strong> field.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">This field is mandatory, not for the name you can assign it of your own choice, but for the characteristics it has and each table must have at least one. The feature that distinguishes the <strong>id<\/strong> field is the activation of the <strong>identity<\/strong> property, this property makes the id field a auto-increment field, that is, the content of this field is managed only and exclusively by SQL SERVER.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">And therefore, with each new insertion of records, the value of this field is automatically increased by one unit. Therefore we are talking about a field that will contain only and exclusively numbers.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"801\" height=\"625\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-campo-id-autoincremento-1.jpg\" alt=\"create id field auto-increment to query sql server\" class=\"wp-image-8257\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-campo-id-autoincremento-1.jpg 801w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-campo-id-autoincremento-1-300x234.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-campo-id-autoincremento-1-577x450.jpg 577w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/crea-campo-id-autoincremento-1-768x599.jpg 768w\" sizes=\"auto, (max-width: 801px) 100vw, 801px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">SQL SERVER needs a field of this type to be able to uniquely identify a record among the many contained in the table. In fact, SQL SERVER, in order to update or delete a record, uses the contents of the id field to identify the record to be updated with T-SQL statements.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, proceed with the creation of the <strong>anagrafica<\/strong> data table which will have the structure highlighted in green in the figure below:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"727\" height=\"410\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-anagrafica-1.jpg\" alt=\"structure database table anagrafica\" class=\"wp-image-8259\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-anagrafica-1.jpg 727w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-anagrafica-1-300x169.jpg 300w\" sizes=\"auto, (max-width: 727px) 100vw, 727px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now click on the icon depicting a floppy disk, save and assign the registry name to the newly created table. Now, continue with the creation of the tax_code table which will instead have the structure highlighted in green in the figure below:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"847\" height=\"420\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-codici-fiscali-1.jpg\" alt=\"create structure database table codici_fiscali\" class=\"wp-image-8260\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-codici-fiscali-1.jpg 847w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-codici-fiscali-1-300x149.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-codici-fiscali-1-800x397.jpg 800w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/struttura-tabella-codici-fiscali-1-768x381.jpg 768w\" sizes=\"auto, (max-width: 847px) 100vw, 847px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Also in this case click on the icon depicting a floppy disk, save and assign the name code_fiscal to the newly created table. By the way I forgot: \u201c<strong>did you create the self-incrementing id field? I hope so<\/strong>&#8220;.<strong><\/strong><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"5_How_to_populate_tables_with_T-SQL\"><\/span><strong>5. How to populate tables with T-SQL<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">We already talked about T-SQL, remember? It is the language used to write SQL Queries in SQL SERVER. Well, now we&#8217;re going to start getting to grips with some SQL commands, so let&#8217;s start populating the two created tables with data that is useful for building queries.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Therefore, click on the New Query button and type the instructions shown in the figure, then press the Execute button.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"796\" height=\"508\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/popola-tabelle-1.jpg\" alt=\"insert records into tables to query sql server\" class=\"wp-image-8262\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/popola-tabelle-1.jpg 796w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/popola-tabelle-1-300x191.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/popola-tabelle-1-705x450.jpg 705w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/popola-tabelle-1-768x490.jpg 768w\" sizes=\"auto, (max-width: 796px) 100vw, 796px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Our two tables have been populated with fictional data for the sole purpose of being able to write SQL queries and return the expected result sets. Now, however, let&#8217;s verify the contents of the two tables by typing our first SQL query. Then, click the <strong>New Query<\/strong> button and type the following SQL statement:<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><span style=\"color:#0693e3\" class=\"tadv-color\">SELECT <\/span>* <span style=\"color:#0693e3\" class=\"tadv-color\">FROM <\/span>Anagrafica<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now click on the Execute button. You will notice that in the window below the one containing the SELECT statement, all the records of the <strong>anagrafica<\/strong> data table have been listed and previously inserted with the INSERT statements.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"488\" height=\"315\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/istruzione-select-anagrafica-1.jpg\" alt=\"instruction select records into anagrafica\" class=\"wp-image-8264\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/istruzione-select-anagrafica-1.jpg 488w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/istruzione-select-anagrafica-1-300x194.jpg 300w\" sizes=\"auto, (max-width: 488px) 100vw, 488px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Now, you can try to check the contents of the tax_codes table by typing the SELECT * FROM codici_fiscali statement, repeating the same operations performed previously for the <strong>anagrafica<\/strong> data table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"6_The_best_way_to_Query_SQL_SERVER\"><\/span><strong>6. The best way to Query SQL SERVER<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Many less experienced programmers use MS Access wizards to produce queries to be fed to SQL SERVER. Unfortunately, the declarative nature of SQL SERVER is completely different from that offered by MS Access. Hence, it is totally wrong to copy and paste queries from MS Access to SQL SERVER or other DBRMS. I&#8217;m sorry, but you have no escape, queries, with SQL SERVER, you have to write them from scratch.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, let&#8217;s not waste time and try to focus on how the SQL SERVER database engine cycles through data. It may seem strange to you but the point is all there. When we typed the SELECT command we gave the order to SQL SERVER to cycle through all the records of a table. Keep in mind that a SELECT statement can also operate on multiple tables at the same time, but there is always a table that is the main one, that is, the one on which the main data loop operates.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"61_The_aliases\"><\/span><strong>6.1 The aliases<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Fortunately, the SELECT statement is not an armored statement, on the contrary, SELECT allows you to customize the returned result set by working a lot with aliases. That is, whenever you enter the name of a table, in a query, it is always convenient to associate an <strong>alias<\/strong> to the table name, in this form:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><span style=\"color:#0693e3\" class=\"tadv-color\">SELECT<\/span> A.* <span style=\"color:#0693e3\" class=\"tadv-color\">FROM<\/span> anagrafica <span style=\"color:#0693e3\" class=\"tadv-color\">AS<\/span> A<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">But what is the importance of the alias &#8220;<strong>A<\/strong>&#8220;? The alias allows us to refer, during the scanning of the records by SQL SERVER, to the fields of the <strong>anagrafica<\/strong> data table and process their contents record after record.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">For example, if you want to recover the tax code of each name, the previous instruction could become:<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><span style=\"color:#0693e3\" class=\"tadv-color\">SELECT<\/span> A.Cognome, A.Nome, (\n                              <span style=\"color:#0693e3\" class=\"tadv-color\">SELECT TOP 1 <\/span>C.codice_fiscale \n                              <span style=\"color:#0693e3\" class=\"tadv-color\">FROM <\/span>codici_fiscali <span style=\"color:#0693e3\" class=\"tadv-color\">AS <\/span>C\n                              <span style=\"color:#0693e3\" class=\"tadv-color\">WHERE <\/span>C.id = A.id\n                          )\n<span style=\"color:#0693e3\" class=\"tadv-color\">FROM <\/span>anagrafica <span style=\"color:#0693e3\" class=\"tadv-color\">AS <\/span>A\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Taking a look at the previous SELECT statement, we can see that it is now possible to process the content of each individual registry record by following a sort of code block, formed by the two round brackets, within which it is possible to recover, thanks to the aliases, fields or contents of other tables as well. That is, interpose an SQL Query, even a very complex one, between the list of fields in the SELECT clause.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">So, thanks to aliases now, instead of a field name in the main table, which is to be scanned, it is possible to insert code to retrieve contents, execute functions, or perform calculations.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">This technique is the one that will allow you to understand how to interact, while scanning a table, with the data retrieved from other tables from time to time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"i\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"970\" height=\"666\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1.jpg\" alt=\"query to sql server\" class=\"wp-image-8265\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1.jpg 970w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1-300x206.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1-655x450.jpg 655w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1-768x527.jpg 768w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/risultato-della-scansione-di-sql-server-1-130x90.jpg 130w\" sizes=\"auto, (max-width: 970px) 100vw, 970px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>READ MORE: <a href=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/web-app-development-with-wordpress-php-and-codeless-framework\/\" target=\"_blank\" rel=\"noreferrer noopener\">Web app development with WordPress, PHP and CodeLess Framework.<\/a><\/p><\/blockquote><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"62_Condition-based_processing_the_CASE_command\"><\/span><strong>6.2 Condition-based processing; the CASE command<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Another aspect not to be overlooked when processing an SQL query is the ability to subject the values retrieved during the scan to conditional expressions.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">e.g.:<\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code><span style=\"color:#0693e3\" class=\"tadv-color\">SELECT <\/span>A.Cognome, A.Nome,\n(\n   <span style=\"color:#0693e3\" class=\"tadv-color\">CASE\n      WHEN<\/span> (\n             <span style=\"color:#0693e3\" class=\"tadv-color\">SELECT TOP 1<\/span> <span style=\"color:#0693e3\" class=\"tadv-color\">SUBSTRING<\/span>(C.Codice_fiscale, 7, 2)\n             <span style=\"color:#0693e3\" class=\"tadv-color\">FROM <\/span>Codici_fiscali AS C\n             <span style=\"color:#0693e3\" class=\"tadv-color\">WHERE <\/span>C.id = A.id\n           ) = '87' <span style=\"color:#0693e3\" class=\"tadv-color\">THEN <\/span>'&gt;= 34 year old' \n      <span style=\"color:#0693e3\" class=\"tadv-color\">ELSE <\/span>'less than 34 year old'\n   <span style=\"color:#0693e3\" class=\"tadv-color\">END\n<\/span>\n) <span style=\"color:#0693e3\" class=\"tadv-color\">AS <\/span>'age'\n<span style=\"color:#0693e3\" class=\"tadv-color\">FROM <\/span>Anagrafica <span style=\"color:#0693e3\" class=\"tadv-color\">AS <\/span>A;\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">Our example SQL Query has now been modified by interposing conditional statements to fetch data from other tables. From here it is clear how it is possible to cycle at the same time on the data of the main table and at the same time evaluate conditional expressions.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In this case <strong>WHEN<\/strong> evaluates the year contained in the tax_code field, retrieved with a SELECT in the tax_code table, and if equal to 87 it returns the string <strong>&#8216;&gt; = 34 years<\/strong> old&#8217; as the content of the calculated field &#8216;<strong>age<\/strong> &#8216;, otherwise it returns the string &#8216;<strong>Less than 34 years old<\/strong>&#8216;.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In short, by appropriately combining Aliases and conditional expressions it is possible to obtain <strong>complex result sets<\/strong> in the face of even very compact code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"7_W3Schoolscom_the_interactive_online_portal_for_developers\"><\/span><strong>7. W3Schools.com the interactive online portal for developers<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">For years now there has been an interactive portal on the net where it is possible to try scripts in any language. T-SQL is no exception, in fact, <a href=\"https:\/\/www.w3schools.com\/sql\/default.asp\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">at this address<\/a> you can practice all the SQL SERVER commands in an environment specifically designed to guarantee easier and more immediate learning.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In <a href=\"https:\/\/www.w3schools.com\/sql\/default.asp\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">W3Schools.com<\/a> you will find thousands of code examples to try instantly using an online editor, you will have the possibility to edit the examples and run the code on your computer within the browser window, to see how your script works, before implementing it.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1602\" height=\"690\" src=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1.jpg\" alt=\"query sql server with w3schools.com \" class=\"wp-image-8266\" style=\"object-fit:cover\" srcset=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1.jpg 1602w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1-300x129.jpg 300w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1-800x345.jpg 800w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1-768x331.jpg 768w, https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/w3schools-1-1536x662.jpg 1536w\" sizes=\"auto, (max-width: 1602px) 100vw, 1602px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">The topic covered in this guide is very broad and the suggested method for writing SQL Server Queries is to be considered as a starting point for entering the fantastic world of remote database programming.<\/p>\n\n\n\n<p class=\"has-medium-font-size wp-block-paragraph\">In any case, I suggest you follow this video tutorial where you will be able to get further tips, in this area, and other useful commands to optimize the writing of SQL Query.<\/p>\n\n\n\n<figure class=\"wp-block-embed aligncenter is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Best Way to Write Basic SQL Queries\" width=\"800\" height=\"450\" src=\"https:\/\/www.youtube.com\/embed\/Z_hEj2U_5tI?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" allowfullscreen><\/iframe>\n<\/div><figcaption class=\"wp-element-caption\"><a href=\"https:\/\/youtu.be\/Z_hEj2U_5tI\" target=\"_blank\" rel=\"noreferrer noopener\">The Best way to write SQL Que<\/a><a href=\"https:\/\/youtu.be\/Z_hEj2U_5tI\">ries<\/a><\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.<\/p>\n","protected":false},"author":1,"featured_media":8245,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[268,1059],"tags":[5090,4203,2810,5187,4086,2941,2937,3799,5181,2943,2837,3040,3868,4205,2945,2356,3044,2839,3688,3690,2841,2843,2845,2939,1039],"class_list":["post-8239","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-articles-en","category-development","tag-ai-en","tag-browser-en","tag-development-en","tag-framework-en","tag-guide-en","tag-how-en","tag-how-to-en","tag-internet-en","tag-microsoft-en","tag-mouse-en","tag-new-en","tag-online-en","tag-php-en","tag-server-en","tag-software-en","tag-sql-server-development-windows","tag-system-en","tag-to-en","tag-tool-en","tag-tools-en","tag-tutorial-en","tag-video-en","tag-web-en","tag-windows-en","tag-wordpress-en"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>The best method to Query SQL SERVER<\/title>\n<meta name=\"description\" content=\"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.\" \/>\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.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The best way to Query SQL SERVER.\" \/>\n<meta property=\"og:description\" content=\"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Antonio Lamorgese\" \/>\n<meta property=\"article:published_time\" content=\"2021-11-21T13:19:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-08T16:49:09+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"450\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Antonio Lamorgese\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"The best way to Query SQL SERVER.\" \/>\n<meta name=\"twitter:description\" content=\"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg\" \/>\n<meta name=\"twitter:creator\" content=\"@AntonioLamorge3\" \/>\n<meta name=\"twitter:site\" content=\"@AntonioLamorge3\" \/>\n<meta name=\"twitter:label1\" content=\"Scritto da\" \/>\n\t<meta name=\"twitter:data1\" content=\"Antonio Lamorgese\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"TechArticle\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/\"},\"author\":{\"name\":\"Antonio Lamorgese\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#\\\/schema\\\/person\\\/264cf3af38edc93a3362a4c47ec5b2f0\"},\"headline\":\"The best method to Query SQL SERVER\",\"datePublished\":\"2021-11-21T13:19:52+00:00\",\"dateModified\":\"2023-09-08T16:49:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/\"},\"wordCount\":2180,\"publisher\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#\\\/schema\\\/person\\\/264cf3af38edc93a3362a4c47ec5b2f0\"},\"image\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/The-best-way-to-Query-SQL-SERVER.jpg\",\"keywords\":[\"AI\",\"browser\",\"development\",\"framework\",\"Guide\",\"how\",\"how to\",\"internet\",\"microsoft\",\"mouse\",\"new\",\"online\",\"php\",\"server\",\"software\",\"Sql server; development; windows;\",\"system\",\"to\",\"tool\",\"tools\",\"tutorial\",\"video\",\"web\",\"windows\",\"wordpress\"],\"articleSection\":[\"Blog Articles\",\"Development\"],\"inLanguage\":\"it-IT\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/\",\"url\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/\",\"name\":\"The best method to Query SQL SERVER\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/The-best-way-to-Query-SQL-SERVER.jpg\",\"datePublished\":\"2021-11-21T13:19:52+00:00\",\"dateModified\":\"2023-09-08T16:49:09+00:00\",\"description\":\"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/The-best-way-to-Query-SQL-SERVER.jpg\",\"contentUrl\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2021\\\/11\\\/The-best-way-to-Query-SQL-SERVER.jpg\",\"width\":800,\"height\":450,\"caption\":\"query sql server\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/the-best-way-to-query-sql-server\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Development\",\"item\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/en\\\/category\\\/development\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"The best method to Query SQL SERVER\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#website\",\"url\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/\",\"name\":\"Antonio Lamorgese\",\"description\":\"Il web e i suoi strumenti operativi\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#\\\/schema\\\/person\\\/264cf3af38edc93a3362a4c47ec5b2f0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/#\\\/schema\\\/person\\\/264cf3af38edc93a3362a4c47ec5b2f0\",\"name\":\"Antonio Lamorgese\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/ChiSono.png\",\"url\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/ChiSono.png\",\"contentUrl\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/ChiSono.png\",\"width\":120,\"height\":130,\"caption\":\"Antonio Lamorgese\"},\"logo\":{\"@id\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/wp-content\\\/uploads\\\/2019\\\/06\\\/ChiSono.png\"},\"description\":\"Amministratore di rete e sviluppatore. Dopo anni di esperienza nel settore, ho ideato un sistema di gestione dati MYSQL in PHP senza scrivere una sola riga di codice.&nbsp;Scopri di pi\u00f9....\",\"sameAs\":[\"https:\\\/\\\/www.Phpcodewizard.it\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/in\\\/antonio-lamorgese-660735190\\\/\",\"https:\\\/\\\/pinterest.it\\\/antoniolamorgese9711\\\/\",\"https:\\\/\\\/x.com\\\/AntonioLamorge3\",\"https:\\\/\\\/www.youtube.com\\\/user\\\/antoniolamorgese\",\"https:\\\/\\\/tumblr.com\\\/blog\\\/phpcodewizard\"],\"url\":\"https:\\\/\\\/www.phpcodewizard.it\\\/antoniolamorgese\\\/author\\\/antonio-lamorgese\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The best method to Query SQL SERVER","description":"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.","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.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/","og_locale":"it_IT","og_type":"article","og_title":"The best way to Query SQL SERVER.","og_description":"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.","og_url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/","og_site_name":"Antonio Lamorgese","article_published_time":"2021-11-21T13:19:52+00:00","article_modified_time":"2023-09-08T16:49:09+00:00","og_image":[{"width":800,"height":450,"url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","type":"image\/jpeg"}],"author":"Antonio Lamorgese","twitter_card":"summary_large_image","twitter_title":"The best way to Query SQL SERVER.","twitter_description":"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.","twitter_image":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","twitter_creator":"@AntonioLamorge3","twitter_site":"@AntonioLamorge3","twitter_misc":{"Scritto da":"Antonio Lamorgese","Tempo di lettura stimato":"15 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"TechArticle","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#article","isPartOf":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/"},"author":{"name":"Antonio Lamorgese","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#\/schema\/person\/264cf3af38edc93a3362a4c47ec5b2f0"},"headline":"The best method to Query SQL SERVER","datePublished":"2021-11-21T13:19:52+00:00","dateModified":"2023-09-08T16:49:09+00:00","mainEntityOfPage":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/"},"wordCount":2180,"publisher":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#\/schema\/person\/264cf3af38edc93a3362a4c47ec5b2f0"},"image":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","keywords":["AI","browser","development","framework","Guide","how","how to","internet","microsoft","mouse","new","online","php","server","software","Sql server; development; windows;","system","to","tool","tools","tutorial","video","web","windows","wordpress"],"articleSection":["Blog Articles","Development"],"inLanguage":"it-IT"},{"@type":"WebPage","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/","url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/","name":"The best method to Query SQL SERVER","isPartOf":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#primaryimage"},"image":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#primaryimage"},"thumbnailUrl":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","datePublished":"2021-11-21T13:19:52+00:00","dateModified":"2023-09-08T16:49:09+00:00","description":"Knowing how to write SQL SERVER Query is essential for a developer, even more, to understand the logic. In this guide the method to do it.","breadcrumb":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#primaryimage","url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","contentUrl":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2021\/11\/The-best-way-to-Query-SQL-SERVER.jpg","width":800,"height":450,"caption":"query sql server"},{"@type":"BreadcrumbList","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/the-best-way-to-query-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/"},{"@type":"ListItem","position":2,"name":"Development","item":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/en\/category\/development\/"},{"@type":"ListItem","position":3,"name":"The best method to Query SQL SERVER"}]},{"@type":"WebSite","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#website","url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/","name":"Antonio Lamorgese","description":"Il web e i suoi strumenti operativi","publisher":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#\/schema\/person\/264cf3af38edc93a3362a4c47ec5b2f0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":["Person","Organization"],"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/#\/schema\/person\/264cf3af38edc93a3362a4c47ec5b2f0","name":"Antonio Lamorgese","image":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2019\/06\/ChiSono.png","url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2019\/06\/ChiSono.png","contentUrl":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2019\/06\/ChiSono.png","width":120,"height":130,"caption":"Antonio Lamorgese"},"logo":{"@id":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-content\/uploads\/2019\/06\/ChiSono.png"},"description":"Amministratore di rete e sviluppatore. Dopo anni di esperienza nel settore, ho ideato un sistema di gestione dati MYSQL in PHP senza scrivere una sola riga di codice.&nbsp;Scopri di pi\u00f9....","sameAs":["https:\/\/www.Phpcodewizard.it\/","https:\/\/www.linkedin.com\/in\/antonio-lamorgese-660735190\/","https:\/\/pinterest.it\/antoniolamorgese9711\/","https:\/\/x.com\/AntonioLamorge3","https:\/\/www.youtube.com\/user\/antoniolamorgese","https:\/\/tumblr.com\/blog\/phpcodewizard"],"url":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/author\/antonio-lamorgese\/"}]}},"permalink_manager":null,"_links":{"self":[{"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/posts\/8239","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/comments?post=8239"}],"version-history":[{"count":2,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/posts\/8239\/revisions"}],"predecessor-version":[{"id":24385,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/posts\/8239\/revisions\/24385"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/media\/8245"}],"wp:attachment":[{"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/media?parent=8239"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/categories?post=8239"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phpcodewizard.it\/antoniolamorgese\/wp-json\/wp\/v2\/tags?post=8239"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}