Pass file name dynamically to OpenRowSet in sqlserver 2000

Posted by Mahendrabasutkar under Sql Server on 7/14/2011 | Points: 10 | Views : 4342 | Status : [Member] | Replies : 3
How to pass file name dynamically to OpenRowSet, while reading data from xls file and putting into sql table using sql server 2000

Regards,
mahendrabasutkar




Responses

Posted by: Lakn2 on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
Refer this

http://msdn.microsoft.com/en-us/library/aa276850(v=sql.80).aspx

Thanks&Regards
LakshmiNarayana Nalluri.

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Umeshdwivedi on: 7/15/2011 [Member] Starter | Points: 25

Up
0
Down
hallo

try this
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)


Latest Technology Trainer
And Part time software consultant

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Usejoy78 on: 7/16/2011 [Member] Starter | Points: 25

Up
0
Down
awosome

Brassbuilder wholesale hardware

Mahendrabasutkar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response