How to import Excel into Sql table by using Store Procedure?

 Posted by Saranya Boopathi on 8/28/2013 | Category: .NET Framework Interview questions | Views: 5490 | Points: 40
Answer:

Exec SP_Excel 'Report.XLSb'

Create PROC SP_Excel 

(
@ExcelName VARCHAR(100)
)
As
Begin
Declare @SQL VARCHAR(1000)
if OBJECT_ID('Table1') is not null
drop table Table1

SET @SQL= 'select * INTO Table1 from openrowset (''Microsoft.ACE.OLEDB.12.0'',''Excel 12.0;Database=d:\Sharedd\'+@ExcelName+''',[Sheet1$])'
EXEC(@SQL)

End


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response

More Interview Questions by Saranya Boopathi