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
Try this
Create a temp table
Then to insert row into hrtc using temptable, any missing columns will have null