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

```
What I often end up doing in these situations is to do some code completion using excel's CONCATENATE function.

Let's say you have:

```
     A     B
1  foo     bar
2  test2   bar2
3  test3   bar 3

```

If you needed to insert those into a table. In column C you can write:

```
=CONCATENATE("INSERT INTO HRTC(col, col2) VALUES('", A1, "','", B1, "')")

```