I'm concatenating multiple table rows into one row. Below code is the working only with nvarchar data type but not with int.
- ALTER PROCEDURE [dbo].[spViewConcatenatedPolicyCInoForTaxInvoice_motorOnly]
-
- @TaxInvoiceNumber nvarchar(50)
- AS
- BEGIN
-
- DECLARE @MotorCINo int
- SET @MotorCINo=''
-
- SELECT @MotorCINo = @MotorCINo + MotorCINo +', '
- FROM CashierSalesDetails
- WHERE TaxInvoiceNumber = @TaxInvoiceNumber
- SELECT LEFT(@MotorCINo,LEN(@MotorCINo)-1) AS PolicyCINo
-
- END
below is the error:
- Msg 245, Level 16, State 1, Procedure spViewConcatenatedPolicyCInoForTaxInvoice_motorOnly, Line 17
- Conversion failed when converting the varchar value ', ' to data type int.
Any is greatly appreciated.