getting error on yellow hightlight below:
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ')'
DougP
Msg 102, Level 15, State 1, Line 8
Incorrect syntax near ')'
Code:
Alter Procedure sp_SOWExportToExcel
AS
Declare @File as nvarchar(300)
Declare @sqlString as nvarchar(max)
Declare @sqlString1 as nvarchar(max)
set @File= 'd:\apps\SOWTimeReportingExcelExports\SOWTimeReporting.xls;'
set @sqlString1 ='Select Vendor,ResourceLastName,ResourceFirstName,
ResourceType, OffshoreOnShore, [Year],
[Month], [Day], SPMID, CostTracker, ADActivityCode as ADA,
HoursWorked as Hours, ApprovedBy,
Convert(nvarchar(15),ApprovedDate,101) as ApprovedDate,
SOWtr.[CostCenter] from dbo.SOWTimeReporting SOWtr
Where [Month] in ( 1, 2, 3, 4) And [Year] = 2013
Order by [Month] DESC, ResourceLastName, ResourceFirstName, [Day]'
SELECT @sqlString = 'INSERT INTO OPENROWSET(' +
'''Microsoft.ACE.OLEDB.12.0'', ' +
'''Excel 12.0;Database=' + @File +', ' + '' + @sqlString1 + ''[highlight #FCE94F]')'[/highlight]
EXEC (@sqlString)
-- EXEC sp_SOWExportToExcel
DougP