Question: I have a table `HRTC` in SQL Server. I want to import data which is in Excel into this table. But my Excel file does not have all the columns which match the `HRTC` table. Is there anyway I can do this?

I am thinking something like in the import wizard

```
Insert into SQLServerTable Select * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=D:\testing.xls;HDR=YES', 
'SELECT * FROM [SheetName$]')

 select column1, column2 from HRTC

```

Answer: 
Try this 

Create a temp table

```
Select * INTO TmpTable FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0', 
'Excel 8.0;Database=D:\testing.xls;HDR=YES', 
'SELECT * FROM [SheetName$]')

```

Then to insert row into hrtc using temptable, any missing columns will have null 

```
INSERT INTO hrtc(column1, column2)
select col1, col2 from TmpTable

```
One simple approach is to script your excel file into a collection of insert statement, then run it on SQL Server.

Also if you can export your excel file into CSV file, this is often useful. Tool like SQL Server Management Studio should have some kind of import wizard where you can load the CSV, choose column mapping etc.