1
DECLARE @path VARCHAR(100)
DECLARE @curdate VARCHAR(80)
DECLARE @type VARCHAR(100)
DECLARE @path2 VARCHAR(200)

SET @path = 'C:\Users\COMPUTERA\Desktop\Dropboxtry\Versions_'
SET @curdate = CONVERT(VARCHAR(12), GETDATE(), 112)
SET @type = '.xls'
SET @path2 = @path + @curdate + @type


insert into @table1
select A.AppName,A.VERSION,B.VERSION,C.VERSION,E.VERSION,D.VERSION
--D.VERSION,E.VERSION,F.VERSION
FROM OPENROWSET ('Microsoft.Jet.OLEDB.4.0' , 'Excel 8.0;Database='+@path2+'', [UBI_1$]) a

I'm getting an error :

Msg 102, Level 15, State 1, Procedure fnApplicationVersion, Line 29
Incorrect syntax near '+'.

Btw I'd like to make it as a function.

Please help, thanks in advance.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    http://stackoverflow.com/a/6621668/29995, perhaps. – Rob Hruska Jan 30 '14 at 03:57
  • You **cannot** make this a function since functions are **not** allowed to make modifications to database table, e.g. you cannot insert, update, delete inside a function – marc_s Jan 30 '14 at 06:01

0 Answers0