AuthorQuestion
Incorrect syntax near the keyword 'select'
Posted on: 17 Dec 2012
Gtting h error:

Msg 156, Level 15, State 1, Procedure sp_DcPymentnsert, Line 16
Incorrect syntax near the keyword 'select'.
Msg 156, Level 15, State 1, Procedure sp_DcPymentnsert, Line 18
Incorrect syntax near the keyword 'select'.
Msg 156, Level 15, State 1, Procedure sp_DcPymentnsert, Line 20
Incorrect syntax near the keyword 'select'.

my pocedure

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        Anil K John
-- Create date: 1/12/2012
-- Description:    Daily collection Payment
-- =============================================
CREATE PROCEDURE sp_DcPymentnsert
    (
    @iChitId int,
    @iRegId int,
    @fPaidAmount float,
    @dPaidate datetime
    )
AS
BEGIN
declare @fInstmount float
set @fInstmount=select fInstmount from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId)   
declare @dInstDate datetime
set @dInstDate=select dInstDate from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId)
declare @Balance float
set @Balance=select fInstmount-fPaidAmount from tblDCPayment where iChitId=@iChitId and iRegId=@iRegId
INSERT INTO tblDCPayment(iChitd,iRegId,iInstNo,fInstAmount,dInstDate,fPaidAmount,fBalance,dPaidDate)
VALUES(@iChitId,@iRegId,'1',@fInstmount,@dInstDate,@fPaidAmount,@Balance,@dPaidate)
       
END
GO


[ + ]
AuthorReply
anil john
  • 0
  • 0
Re: Incorrect syntax near the keyword 'select'
Posted on: 17 Dec 2012  
set @fInstmount=(select fInstmount from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId))   
declare @dInstDate datetime
set @dInstDate=(select dInstDate from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId))
declare @Balance float
set @Balance=(select fInstmount-fPaidAmount from tblDCPayment where iChitId=@iChitId and iRegId=@iRegId)

Re: Incorrect syntax near the keyword 'select'
Posted on: 17 Dec 2012  
hi
u need to give brakets
example :
declare @qty int
set @qty=(select qty from tablename)


u can execute the fallowing procedure.
CREATE PROCEDURE sp_DcPymentnsert
    (
    @iChitId int,
    @iRegId int,
    @fPaidAmount float,
    @dPaidate datetime
    )
AS
BEGIN
declare @fInstmount float
set @fInstmount=(select fInstmount from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId))   
declare @dInstDate datetime
set @dInstDate=(select dInstDate from tblChitInstalments where iChitId=@iChitId and iInstNo=(select max(iInstNo) from tblDCPayment where ichitId=@iChitId))
declare @Balance float
set @Balance=(select fInstmount-fPaidAmount from tblDCPayment where iChitId=@iChitId and iRegId=@iRegId)
INSERT INTO tblDCPayment(iChitd,iRegId,iInstNo,fInstAmount,dInstDate,fPaidAmount,fBalance,dPaidDate)
VALUES(@iChitId,@iRegId,'1',@fInstmount,@dInstDate,@fPaidAmount,@Balance,@dPaidate


Thanks & Regards
Ravi Kumar

Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.
Join a Chapter