Presentation is loading. Please wait.

Presentation is loading. Please wait.

Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number If you came to this presentation.

Similar presentations


Presentation on theme: "Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number If you came to this presentation."— Presentation transcript:

1 Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number If you came to this presentation via a web browser, right-click and choose Full Screen before proceeding. Click mouse or press space bar to continue. This presentation was prepared by Professor Steve Ross, with the advice of other MIS Faculty, for use in MIS Classes at Western Washington University. Please contact Dr. Ross for permission to use in other settings..Dr. Ross The Sister Cities Database Development Project

2 Wizards are Wonderful, but … Complications are not uncommon with import Wizards. The Wizard interprets the data according to the rules it has been programmed with. Sometimes that interpretation incorrect. One such problem can occur when the Excel data contains strings that look like numbers, but are not actually numbers. For example, telephone numbers or ZIP codes. The Wizard will define the phone number in the import table as a numeric field in the database table it creates. The phone numbers and the ZIP codes get corrupted in the process.

3 Solutions to the Wizard Problem Solutions to this particular problem may include… 1.Exporting the data from the Excel spreadsheet to a text file (e.g. NotePad) first, then importing the data from the NotePad document, rather than directly from the spreadsheet. 2.Modifying the data in the Excel spreadsheet so it is clearly a string. For example, you could add x to the beginning of every phone number or ZIP code: X If you modify the data, of course you must undo the alteration after the data has been imported. The following slides show how Method 1 might be implemented. For extra practice, you can try Method 2 on your own.

4 Export the Spreadsheet 2.File tab – Save As command a.Give the file a recognizable name, e.g., WorkersTab b.Save as type: Text (Tab delimited) c.If there are multiple sheets, a dialog box will ask if it is OK to save only active sheet – click OK

5 3.Import the data a.Right-click Database name; choose Tasks; choose Import Data…; click Next > on the splash screen b.Choose the Data Source (Flat File Source) and browse to locate the file c.Note these settings d.click Next > twice Import the Data

6 3.Import the data e.Choose the destination then click Next >

7 Import the Data 3.Import the data f.Select Source Table g.Click Edit Mappings… (see next slide)

8 Import the Data 3.Import the data g.Click Edit Mappings… change as req., click OK, then Next > h.{ on the next screen } Choose Run Package immediately; click Next > i.{ on the next screen } Click Finish

9 Import the Data 3.Import the data j.Read the report, then Close.

10 Verify the Results 4.Inspect the table (right-click table name, choose Select Top 1000 Rows) a.Data in expected columns b.Numeric data format, ensure no loss c.Character data, check for truncation

11 Analyze Data in Import Table 5.Modify the SELECT query created in Step 4 … a.Remove TOP 1000 b.Add functions to determine maximum length of strings and maximum value of numbers: SELECT MAX(LEN([LastName])) AS [LastName],MAX(LEN([FirstName])) AS [FirstName],MAX(LEN([MidName])) AS [MidName],MAX([AnnualPay1000]) AS [AnnualPay1000],MAX(LEN([DepartmentName])) AS [DepartmentName],MAX(LEN([Rank])) AS [Rank],MAX([BudgetAuthorityIn1000]) AS [BudgetAuthorityIn1000],MAX([PersonalStaff]) AS [PersonalStaff],MAX(LEN([MailCode])) AS [MailCode] FROM [createdbexample].[dbo].[WorkersTab]

12

13 Create and Populate the Final Table As with the method demonstrated in … ImportingData - General Case (including data with large strings and integers) … you should then build a final table and copy the data from the temporary import table to the final table. SeeImportingData - Moving Data the Import Table to the Final Table for details.


Download ppt "Importing Data from a Spreadsheet that contains Phone Numbers, ZIP Codes and other similar string data that looks like a number If you came to this presentation."

Similar presentations


Ads by Google