Click here to Skip to main content
15,891,852 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hallo to all

How to pass file name dynamically to OpenRowSet, while reading data from xls file and putting into sql table using sql server 2000
Posted

1 solution

Try something like this in procedure
DECLARE @docpath nvarchar(200)
SET  @docpath = 'E:\Workflow\SPP\Attachments\TR\ExcelUpload\claim.xls'
DECLARE @sql nvarchar(1000)
SET @sql = 'INSERT INTO [YourTable] ([Column1], [Column2]) SELECT A.[Column1], A.[Column2] FROM OPENROWSET (''Microsoft.ACE.OLEDB.12.0'', ''Excel 12.0;;Database=' + @docpath + ''', ''select * from [Sheet1$]'') AS A'
exec(@sql)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900