官术网_书友最值得收藏!

Reading multiple tables from MSSQL

In this section, you will learn how to read multiple tables. In practice, the data that you will need will span multiple tables and is usually not found in a single table. We will import the following tables:

Users: This table holds information about all of the home owners who want to rent their homes. Data, such as their name, address, phone number, and registration date, will be found in this table.

PmtHistory: This table captures the data after a user applies to a rental property. It includes information, such as the date the application was submitted and the ID number of the property.

Rateplan: This table contains information on how much it costs the owner of the rental property to process an application.

  1. We already know from the Reading a table from MSSQL – the Microsoft SQL Server database section how to import a single table, and we will repeat a lot of these steps but with a few differences. Make sure that you close Excel and open a new workbook. Select the DATA tab, click on the From Other Sources button, and select the From SQL Server option, as shown in Figure 2.1 of the Reading a table from MSSQL – the Microsoft SQL Server database section.
  2. Type the name of your server and click on the Next button, as shown in Figure 2.3 of the Reading a table from MSSQL – the Microsoft SQL Server database section. If you do not know the name of your server, refer to the Reading a table from MSSQL – the Microsoft SQL Server database section for more information.
  3. In the Data Connection Wizard, make sure that you select the Connect to a specific table and the Enable selection of multiple tables options.
    Reading multiple tables from MSSQL

    Figure 2.7

  4. Now, select the database that holds the tables named users, pmthistory, and rateplan by using the drop-down menu. In this example, the database is called BizIntel, and we select this option.
    Reading multiple tables from MSSQL

    Figure 2.8

    After selecting the database, you will see the users, pmthistory, and rateplan tables appear in the middle of the dialog box. Do not worry about the fourth table that shows up, which is named data. This is just an additional table that we can import into Excel if we choose to do so.

  5. Select the three tables named users, pmthistory, and rateplan, as shown in the following screenshot. This action tells Excel that you want to import these specific tables. You have the option of choosing one or more tables in this step.
    Reading multiple tables from MSSQL

    Figure 2.9

  6. You will now see the Import Data dialog box with the PivotTable Report option selected by default. Select the Table option and click on the OK button, as shown in the following screenshot:
    Reading multiple tables from MSSQL

    Figure 2.10

    After you click on the OK button, each table will be placed in a separate sheet. The sheets 2, 3, and 4 will contain the data in the tables named users, pmthistory, and rateplan. That's it! You have just completed the Reading multiple tables from MSSQL section.

主站蜘蛛池模板: 许昌市| 安西县| 广宗县| 南汇区| 普定县| 淮南市| 葵青区| 新巴尔虎右旗| 镇巴县| 象山县| 鹤峰县| 富源县| 桃园县| 南皮县| 金山区| 浦城县| 天等县| 湄潭县| 江门市| 夏津县| 邵阳县| 石首市| 武宣县| 称多县| 崇明县| 阳城县| 太仆寺旗| 安泽县| 西和县| 建水县| 江油市| 东莞市| 罗源县| 崇文区| 若尔盖县| 武汉市| 广宗县| 松溪县| 南京市| 醴陵市| 达拉特旗|