Keywords: Data Import | SQL Server 2008 | Excel | SSIS | Column Mapping
Abstract: This article provides a detailed guide on importing data from Excel 2003 files into SQL Server 2008 databases using the SQL Server Management Studio Import Data Wizard. It addresses common issues in 64-bit environments, offers step-by-step instructions for column mapping configuration, SSIS package saving, and automation solutions to facilitate efficient data migration.
Data migration from Excel spreadsheets to SQL Server databases is a frequent requirement in integration scenarios. Users often encounter driver compatibility issues, such as linked server failures with JET OLE DB Access drivers on 64-bit machines. Based on the best-practice answer, this article systematically explains a reliable import method using SQL Server Integration Services (SSIS).
Core Advantages of the Import Data Wizard
The Import Data Wizard built into SQL Server Management Studio (SSMS) offers a graphical interface that simplifies data transfer from Excel to SQL Server. This tool automatically handles data type conversion, error handling, and workflow management, making it particularly suitable for Excel 2003 (.xls) files. Unlike manual linked server creation, the wizard avoids driver compatibility issues on 64-bit systems by establishing temporary in-memory connections for direct data transfer.
Step-by-Step Operational Process
In SSMS Object Explorer, right-click the target database, select "Tasks" > "Import Data" to launch the wizard. The first step involves choosing "Microsoft Excel" as the data source and locating the Excel file via the file browser. The system automatically detects worksheet structures, and users must confirm the Excel version (e.g., Excel 97-2003).
The second step specifies the destination as "SQL Server Native Client," entering server names and authentication details to select the target database. Key configuration occurs in the third step's mapping settings: select the source worksheet (e.g., Sheet1$) and target table (e.g., Database.dbo.Table1) from dropdown menus. Click the "Edit Mappings" button to access the column mapping interface.
Column Mapping and Structural Transformation
When five columns from an Excel sheet need to map to a SQL Server table with different column names, the mapping interface displays correspondences between source and target columns. Users can adjust each Excel column's corresponding database column via dropdown menus, ensuring data type compatibility (e.g., mapping Excel text to NVARCHAR, numbers to INT). Example code illustrates the pseudo-implementation of mapping logic:
-- Example mapping configuration
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
-- Actual mapping is implemented in SSIS packages via Data Flow Task
-- Source component: Excel Source → Transformation: Derived Column → Destination: SQL Server Destination
After completing mappings, preview data and set error-handling options (e.g., row-level error redirection). The fourth step confirms execution settings, choosing "Run immediately" for a one-time import or "Save SSIS Package" for reuse.
SSIS Package Deployment and Automation
The wizard supports saving the import process as an SSIS package, storing it in the file system or SQL Server's MSDB database. Specify the package name and protection level during saving (e.g., encryption with a password). Once deployed, execute it regularly via SQL Server Agent jobs to automate data loading. The following code illustrates how to invoke an SSIS package via T-SQL:
-- Execute SSIS package via SQL Agent job
USE msdb;
EXEC dbo.sp_add_job
@job_name = N'ExcelImportJob';
-- Add a step to call DTExec for package execution
EXEC dbo.sp_add_jobstep
@command = N'/FILE "C:\SSIS\ExcelImport.dtsx" /CONNECTION "ExcelConn";"Data Source=C:\data.xls;"';
Compatibility and Best Practices
For 64-bit environments, ensure installation of the Microsoft Access Database Engine 2010 Redistributable (32-bit version) to provide Excel driver support. Avoid outdated JET drivers by using SSIS's Excel Connection Manager, which processes .xls files via the ACE OLEDB provider. During testing, use small-scale data to verify mapping accuracy, paying special attention to date formats and null value handling.
Through this method, users can resolve initial driver errors and achieve flexible column renaming and automated scheduling, enhancing data management efficiency. SSIS's extensibility also supports adding data cleansing transformations, laying the foundation for complex data integration scenarios.