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

i am executing following procedure but give this error :

Msg 102, Level 15, State 1, Procedure getdata, Line 12
Incorrect syntax near '@DataFeed'.


SQL
ALTER procedure [dbo].[getdata]
(

@DataFeed varchar(20)='my.xls'


)
as

SELECT *
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\backup\'@DataFeed'', 'select * from [Sheet1$] where area is not null')
Posted
Updated 26-Nov-11 1:02am
v2

1 solution

SQL
FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\backup\' + @DataFeed + '', 'select * from [Sheet1$] where area is not null')

Try this, you need to concatenate the strings using +.
Hope it helps.
 
Share this answer
 
v2
Comments
balongi 26-Nov-11 7:07am    
Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '+'.
balongi 26-Nov-11 7:07am    
it still giving error :

Msg 102, Level 15, State 1, Line 2
Incorrect syntax near '+'.
Sander Rossel 26-Nov-11 7:14am    
There is no + near line 2... You still getting the error?
balongi 26-Nov-11 7:21am    
there is + near line 2, i have added select * from in first line
and in line 2 i added FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\backup\' + @DataFeed + '', 'select * from [Sheet1$] where area is not null') . but it give Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '+'. error
balongi 26-Nov-11 7:30am    
there is + near line 2, i have added select * from in first line and in line 2 i added FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0','Excel 8.0;Database=E:\backup\' + @DataFeed + '', 'select * from [Sheet1$] where area is not null') . but it give Msg 102, Level 15, State 1, Line 2 Incorrect syntax near '+'. error

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