Employers - Post Free Jobs
Forum guidelines
AuthorQuestion
Incorrect syntax near '+'.
Posted on: 30 Aug 2011


        GO
/****** Object:  StoredProcedure [dbo].[Add_Result]    Script Date: 08/30/2011 12:24:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[Update registerno]
(
@filename nvarchar(50),
@sheetname nvarchar(50)
)
AS
BEGIN

UPDATE StudentRegistration SET adno = T.[adno]  
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database=' + @filename + ';HDR=YES', 'SELECT * FROM [Sheet1$]')T  
WHERE StudentRegistration.regno = T.[regno]

END

        The following error occur in above sql query

Msg 102, Level 15, State 1, Procedure Update registerno, Line 12
Incorrect syntax near '+'.


AuthorReply
Jitendra Sampathirao
  • 0
  • 0
accepted
Re: Incorrect syntax near '+'.
Posted on: 30 Aug 2011   Accepted Answer
try this

BEGIN

UPDATE StudentRegistration SET adno = T.[adno] 
FROM OPENROWSET('Microsoft.ACE.OLEDB.12.0', 'Excel 12.0;Database='" + @filename + "';HDR=YES', 'SELECT * FROM [Sheet1$]')T 
WHERE StudentRegistration.regno = T.[regno]

END



If this post helped you, then tick the "Do you like this Answer" checkbox.
Employers - Post Free Jobs

SPONSORED BY

Offshore Software and Database Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.