This is very easy and very fast, enough you have few seconds thousands records.
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
GO
EXEC sp_configure 'ad hoc distributed queries', 1
RECONFIGURE
GO
INSERT INTO t_table (c_col1, c_col2, c_col3, c_col4)
SELECT A.c_ids, A.c_c_names, A.c_accs, A.c_last
FROM OPENDATASOURCE('Microsoft.ACE.OLEDB.12.0','Data Source=D:\Documents\users.xlsx;Extended Properties=Excel 12.0')...[Sheet1$] as A
contains:
- D:\Documents\users.xlsx - excell file path
- Extended Properties=Excel 12.0 - means MS office 2007
- [Sheet1$] as A - means renamed sheet1 to A
- A.c_ids, A.c_c_names, A.c_accs, A.c_last - columns on excel file
No comments:
Post a Comment