0
BEGIN
    DECLARE
        @NewInvoiceName VARCHAR(20); DECLARE @PreFix VARCHAR(10) = 'TCC'; DECLARE @Id INT;
    SELECT
        @Id = ISNULL(MAX(ID),
        0) + 1
    FROM
        Invoice_Details
    SELECT
        @NewInvoiceName = @PreFix + RIGHT(
            '000' + CAST(@Id AS VARCHAR(7)),
            7
        )
    INSERT
        INTO
            Invoice_Details
        VALUES(
            @NewInvoiceName,
            @NewInvoiceAmount,
            @NewInvoiceDate,
            @NewInvoiceSubmitted,
            @NewInvoiceSubmitDate,
            @NewRemarks
        )
END

I want to solve the error:

MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@NewInvoiceName VARCHAR(20); DECLARE @PreFix VARCHAR(10) = 'TCC'; DECLARE @Id IN' at line 3

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149

0 Answers0