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

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.

主站蜘蛛池模板: 九龙坡区| 衡南县| 南昌县| 永宁县| 郴州市| 托克逊县| 田东县| 揭阳市| 松桃| 布尔津县| 延边| 洛浦县| 邢台市| 临清市| 阿拉尔市| 陇川县| 营山县| 崇义县| 高雄市| 丹江口市| 保德县| 马山县| 剑河县| 龙口市| 玉屏| 阜平县| 平原县| 德兴市| 堆龙德庆县| 涪陵区| 宜城市| 云南省| 明星| 大冶市| 清远市| 曲松县| 区。| 南澳县| 桃江县| 兰坪| 康平县|