在将单引号添加到此存储过程最后一行的最后一个单词时遇到问题
PROCEDURE PROC1(@ProductName nvarchar(40))
AS
BEGIN
DECLARE @sql nvarchar(MAX), @debug bit = 1
SET @sql = 'Select [Created] as [Date],[SerialId],[ProductId], CreatedById as [UserId]
from [Customer].[dbo].[QuotationFlat] QF inner join [Customer].[dbo].[Product] Pt on Pt.Status=QF.' + @ProductName +'
where '+ @ProductName +' = 1 and Productid = (
SELECT Productid
FROM Product
WHERE Productid = (SELECT MAX(Productid) AS Productid
FROM Product
WHERE ProductName = ' + @ProductName + '))'
SELECT @sql
-------------Last line Issue------------------
FROM Product
WHERE ProductName = Test))
----------But there should be single quote around word TEST
1条答案
按热度按时间zd287kbt1#
换行
到