Click here to Skip to main content
14,735,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using an SP such that i am storing the queries in a string and finally after performing manipulations in the string for the various conditions i need to use for the SP, I execute the string in the SP. I am using nvarchar(max) for the queries in SQL Server 2012. However, once the string crosses a limit, it shows "Incorrect Syntax" error . This error disappears if i reduce the lines in the SP. I am sure the SP is correct because when executing the statements separately, I got the result. In the whole SP too, if I remove the whitespaces in the SP, i get the results required. What is the cause of this issue ? Has anyone experienced this before ? I am completely dumbfounded by this.

This is the SP

--CREATE PROCEDURE [dbo].[_PTC_PayOff_Asset_List_Rpt]
-- @CustomerAccountNumber NVARCHAR(MAX) = NULL
-- ,@LeaseSequenceNumber NVARCHAR(MAX) = NULL
--, @PortfolioName NVARCHAR(MAX) = NULL
--,@QuoteStatus NVARCHAR(MAX) = NULL
--,@PayOffQuoteName NVARCHAR(MAX) = NULL

--AS
--use LW_Presidio_Dev
DECLARE @CustomerAccountNumber NVARCHAR(MAX);
DECLARE @LeaseSequenceNumber NVARCHAR(MAX);
DECLARE @PortfolioName NVARCHAR(MAX);
DECLARE @QuoteStatus NVARCHAR(MAX);
DECLARE @PayOffQuoteName NVARCHAR(MAX)

SET @CustomerAccountNumber = '300021';
SET @LeaseSequenceNumber = '41937_a2'; --253
SET @PortfolioName = 'Presidio Technology Capital'; --Presidio Technology Capital
SET @QuoteStatus = ''; --Open
SET @PayOffQuoteName = ''; --1792

IF @CustomerAccountNumber IS NULL BEGIN SET @CustomerAccountNumber = '' END
IF @LeaseSequenceNumber IS NULL BEGIN SET @LeaseSequenceNumber = '' END
IF @PortfolioName IS NULL BEGIN SET @PortfolioName = '' END
IF @QuoteStatus IS NULL BEGIN SET @QuoteStatus = '' END
IF @PayOffQuoteName IS NULL BEGIN SET @PayOffQuoteName = '' END

DECLARE @SQLStatement NVARCHAR(MAX);
SET @SQLStatement = '
;With CTE_SalesRep
AS
(
SELECT
RS1.LeaseID
--, (Security_UserProfile.FirstName) [SalesRep]
,(IsNull(Security_UserProfile.FirstName,'''''+') + ''''
+ IsNull(Security_UserProfile.MiddleName,'''''+') + ''''
+ IsNull(Security_UserProfile.LastName,'''''+')) [SalesRep]
FROM
(
SELECT
EmployeeAssignment_Entity.EntityID [LeaseID]
, MAX(EmployeeAssignment_Entity.EmployeeAssignmentID) [MaxEmployeeAssignmentID]
FROM
EmployeeAssignment_Entity
WHERE
EmployeeAssignment_Entity.EntityTypeID = 5 --Lease
AND EmployeeAssignment_Entity.IsActive = 1 --Yes
AND EmployeeAssignment_Entity.RoleFunctionID = 8 --Sales Representative
GROUP BY
EmployeeAssignment_Entity.EntityID
) RS1

INNER JOIN EmployeeAssignment_Entity
ON EmployeeAssignment_Entity.EmployeeAssignmentID = RS1.MaxEmployeeAssignmentID

INNER JOIN Security_UserProfile
ON Security_UserProfile.UserID = EmployeeAssignment_Entity.UserID
),

CTE_AccountManager
AS
(
SELECT
RS1.LeaseID
--, (Security_UserProfile.FirstName) [AccountManager]
,(IsNull(Security_UserProfile.FirstName,'''''+') + ''''
+ IsNull(Security_UserProfile.MiddleName,'''''+') + ''''
+ IsNull(Security_UserProfile.LastName,'''''+')) [AccountManager]
FROM
(
SELECT
EmployeeAssignment_Entity.EntityID [LeaseID]
, MAX(EmployeeAssignment_Entity.EmployeeAssignmentID) [MaxEmployeeAssignmentID]
FROM
EmployeeAssignment_Entity
WHERE
EmployeeAssignment_Entity.EntityTypeID = 5 --Lease
AND EmployeeAssignment_Entity.IsActive = 1 --Yes
AND EmployeeAssignment_Entity.RoleFunctionID = 4 --Sales Representative
GROUP BY
EmployeeAssignment_Entity.EntityID
) RS1

INNER JOIN EmployeeAssignment_Entity
ON EmployeeAssignment_Entity.EmployeeAssignmentID = RS1.MaxEmployeeAssignmentID

INNER JOIN Security_UserProfile
ON Security_UserProfile.UserID = EmployeeAssignment_Entity.UserID
),

CTE_PayoffReceivable AS
(
SELECT Receivable_Payoff.PayoffQuoteID,Receivable_Payoff.InventoryID
,CASE WHEN Receivable_Payoff.ReceivableTypeID = 4 THEN SUM(Receivable_Payoff.Balance) ELSE 0.00 END As BasePayoffBalance
,CASE WHEN Receivable_Payoff.ReceivableTypeID = 5 THEN SUM(Receivable_Payoff.Balance) ELSE 0.00 END As BaseBuyoutBalance
,Receivable_Payoff.ReceivableTypeID
FROM Receivable_Payoff
--WHERE Receivable_Payoff.PayoffQuoteID = 4
GROUP BY Receivable_Payoff.PayoffQuoteID,Receivable_Payoff.InventoryID,Receivable_Payoff.ReceivableTypeID
),
CTE_ReceivableGroup AS
(
SELECT
CTE_PayoffReceivable.InventoryID
,CTE_PayoffReceivable.PayoffQuoteID
,MAX(BasePayoffBalance) AS BasePayoffBalance
,MAX(BaseBuyoutBalance) AS BaseBuyoutBalance
FROM CTE_PayoffReceivable
GROUP BY
CTE_PayoffReceivable.InventoryID
,CTE_PayoffReceivable.PayoffQuoteID
)
SELECT
GETDATE() [Current Date],
PayOff_Quote.QuoteName [Payoff Quote Name],
PayOff_Quote.PayOffQuoteID [Payoff Quote ID],
Customer_Profile.CustomerName [Customer Name],
--Customer_Profile.CompanyName,
Customer_Profile.AccountNumber [Account Number],
Lease_profile.LeaseNumber [Lease Schedule Number],
Customer_Profile.AccountNumber [Account Number],
Lease_Profile.SequenceNumber [Lease Sequence Number],
CTE_AccountManager.AccountManager,
CTE_SalesRep.SalesRep,
Payoff_FinancialDetail.ComputeDate [Termination Date],
CASE WHEN PayOff_Quote.IsFullPayoff = 1 THEN ''Full'' ELSE ''Partial'' END AS [Termination Quote Type],
PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName [Payoff Quote Status],
Invoice_Number.InvoiceNumber [Invoice Number],
Payoff_QuoteInvoiceHeader.DueDate [Invoice Due Date],
Payoff_QuoteInvoiceHeader.QuoteAmount [Invoice Amount Due],
Inventory_FactorCategoryTemplate.FactorCategoryName [Factor Category Type],
--Lease_Contract.MaturityDate,
Inventory_Profile.Manufacturer,
Inventory_Profile.Quantity,
Inventory_Profile.Description1 [Equipment Description],
Inventory_Profile.SerialNumber [Serial Number],
Payoff_InventoryStatus_CnfgLocale.StatusName AS PayoffInventoryStatus,
--ISNULL(Payoff_FinancialDetail.BasePayOffAmount,0.00) AS TotalBasePayoffAmount,
CTE_ReceivableGroup.BasePayoffBalance
,CTE_ReceivableGroup.BaseBuyoutBalance,
CASE WHEN Payoff_Quote.IsTerminationLetterExecuted = 1 THEN ''Yes'' ELSE ''No'' END As TerminationLetterExecuted,
Inventory_LocationTemplate.LocationCode,
Inventory_Profile.OriginalCost
,Inventory_LocationTemplate.Address
,Inventory_LocationTemplate.Address2
,Inventory_LocationTemplate.City
,Template_State_CnfgLocale.StateShortName
,Inventory_LocationTemplate.ZIP
,ISNULL(Payoff_FinancialDetail.BaseBuyOutAmount,0.00) AS TotalBaseBuyOutAmount
,Inventory_Profile.InventoryID As AssetID
,Inventory_Profile.Alias
,Inventory_Profile.UnitNumber

FROM PayOff_Quote
Inner Join Lease_Profile ON
Lease_Profile.LeaseID = PayOff_Quote.LeaseID
Inner Join Customer_Profile ON
Customer_Profile.CustomerID = Lease_Profile.CustomerID
INNER JOIN PayOff_QuoteStatus_CnfgLocale ON
PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusID = PayOff_Quote.QuoteStatusID
Inner Join Payoff_InventoryInQuote ON
Payoff_InventoryInQuote.PayOffQuoteID = PayOff_Quote.PayOffQuoteID
JOIN Payoff_InventoryStatus_CnfgLocale ON
Payoff_InventoryStatus_CnfgLocale.InventoryPayoffStatusID = Payoff_InventoryInQuote.InventoryPayoffStatusID
Inner Join Inventory_Profile ON
Inventory_Profile.InventoryID = Payoff_InventoryInQuote.InventoryID
Inner Join Inventory_FactorCategoryTemplate ON
Inventory_FactorCategoryTemplate.FactorCategoryID = Inventory_Profile.FactorCategoryID
Inner Join Inventory_Location ON
Inventory_Location.InventoryID = Inventory_Profile.InventoryID
Inner Join Inventory_LocationTemplate ON
Inventory_LocationTemplate.LocationTemplateID = Inventory_Location.LocationTemplateID
JOIN Template_State_CnfgLocale ON
Template_State_CnfgLocale.StateID = Inventory_LocationTemplate.StateID
Inner Join Portfolio_Profile ON
Portfolio_Profile.PortfolioID = Lease_Profile.PortfolioID
JOIN Lease_Contract ON
PayOff_Quote.LeaseID = Lease_Contract.LeaseID
AND Lease_Contract.IsActive = 1
LEFT JOIN CTE_ReceivableGroup ON
CTE_ReceivableGroup.PayoffQuoteID = Payoff_Quote.PayOffQuoteID
AND Payoff_InventoryInQuote.InventoryID = CTE_ReceivableGroup.InventoryID
LEFT Join Payoff_FinancialDetail ON
Payoff_FinancialDetail.PayOffQuoteID = PayOff_Quote.PayOffQuoteID
LEFT JOIN Payoff_QuoteInvoiceLeaseDetail ON
Payoff_QuoteInvoiceLeaseDetail.PayoffQuoteId = PayOff_Quote.PayoffQuoteId
LEFT JOIN Payoff_QuoteInvoiceHeader ON
Payoff_QuoteInvoiceHeader.PayOffQuoteInvoiceID = Payoff_QuoteInvoiceLeaseDetail.PayOffQuoteInvoiceID
LEFT JOIN Invoice_Number ON
Invoice_Number.InvoiceNumberId = Payoff_QuoteInvoiceHeader.InvoiceNumberId
LEFT JOIN CTE_SalesRep ON
CTE_SalesRep.LeaseID = Lease_Profile.LeaseID
LEFT JOIN CTE_AccountManager ON
CTE_AccountManager.LeaseID = Lease_Profile.LeaseID
-- WHERE PayOff_Quote.PayoffQuoteId = 1

PRIMARY_FILTERCONDITIONS'

DECLARE @PrimaryFilterConditions NVARCHAR(MAX)
SET @PrimaryFilterConditions = '';
--IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <=0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
-- BEGIN
-- SET @PrimaryFilterConditions = 'WHERE 1 <> 1';
-- END
IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Customer_Profile.AccountNumber = @CustomerAccountNumber AND Portfolio_Profile.PortfolioName = @PortfolioName AND Payoff_Quote.QuoteName = @PayOffQuoteName AND
PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Portfolio_Profile.PortfolioName = @PortfolioName AND Payoff_Quote.QuoteName = @PayOffQuoteName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END
IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Portfolio_Profile.PortfolioName = @PortfolioName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Customer_Profile.AccountNumber = @CustomerAccountNumber AND Payoff_Quote.QuoteName = @PayOffQuoteName';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Customer_Profile.AccountNumber = @CustomerAccountNumber AND Payoff_Quote.QuoteName = @PayOffQuoteName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName
= @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Portfolio_Profile.PortfolioName = @PortfolioName AND Payoff_Quote.QuoteName = @PayOffQuoteName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @
QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Payoff_Quote.QuoteName = @PayOffQuoteName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Lease_Profile.SequenceNumber = @LeaseSequenceNumber';
END


IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Portfolio_Profile.PortfolioName = @PortfolioName';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Portfolio_Profile.PortfolioName = @PortfolioName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStat
usName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Portfolio_Profile.PortfolioName = @PortfolioName';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) > 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Customer_Profile.AccountNumber = @CustomerAccountNumber AND Payoff_Quote.QuoteName = @PayOffQuoteName';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Portfolio_Profile.PortfolioName = @PortfolioName';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber AND Payoff_Quote.QuoteName = @PayOffQuoteName';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Portfolio_Profile.PortfolioName = @PortfolioName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Portfolio_Profile.PortfolioName = @PortfolioName AND Payoff_Quote.QuoteName = @PayOffQuoteName';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Payoff_Quote.QuoteName = @PayOffQuoteName AND PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

/**/
IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) > 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Lease_Profile.SequenceNumber = @LeaseSequenceNumber';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) > 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Portfolio_Profile.PortfolioName = @PortfolioName';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) > 0 AND LEN(@PayOffQuoteName) <= 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE PayOff_QuoteStatus_CnfgLocale.PayOffQuoteStatusName = @QuoteStatus';
END

IF LEN(@CustomerAccountNumber) <= 0 AND LEN(@LeaseSequenceNumber) <= 0 AND LEN(@PortfolioName) <= 0 AND LEN(@QuoteStatus) <= 0 AND LEN(@PayOffQuoteName) > 0
BEGIN
SET @PrimaryFilterConditions = 'WHERE Payoff_Quote.QuoteName = @PayOffQuoteName';
END

IF LEN(@PrimaryFilterConditions)<=0
BEGIN
SET @PrimaryFilterConditions='WHERE 1=1';
END


SET @SQLStatement = REPLACE(@SQLStatement, 'PRIMARY_FILTERCONDITIONS', @PrimaryFilterConditions)
EXEC sp_executesql @SQLStatement,N'@CustomerAccountNumber NVARCHAR(MAX),@LeaseSequenceNumber NVARCHAR(MAX),@PortfolioName NVARCHAR(MAX),@QuoteStatus NVARCHAR(MAX),@PayOffQuoteName NVARCHAR(MAX)',@CustomerAccountNumber,@LeaseSequenceNumber,@PortfolioName,@QuoteStatus,@PayOffQuoteName
Posted
Updated 3-Apr-14 21:40pm
v2
Comments
Kornfeld Eliyahu Peter 4-Apr-14 2:35am
   
Can you show us the SP and the line with the problem?
Divakar Raj M 4-Apr-14 2:46am
   
Updated. But i dont think you will be able to get the data because you dont have the tables

1 solution

Actually in dynamic query in Sp this issue occurs due to the syntax error or single quotes ("'"). Try checking for this. Still if you face the issue. Please provide your query/SP;
   
Comments
Divakar Raj M 4-Apr-14 2:46am
   
Updated. But i dont think you will be able to get the data because you dont have the tables
Er. Puneet Goel 4-Apr-14 6:36am
   
Yes we know but at least we can rectify the error.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900