在下面,如果我尝试在 BEGIN 语句之后放置一个打印它不起作用,当我删除 BEGIN-END 语句中的所有内容并放置一个打印它时它会起作用;
SET @SQL = 'IF (((SELECT fldLT FROM #zArray) = ''p'') OR ((SELECT fldMF FROM #zArray) <> -1))
BEGIN
SET @X = '+@Z+' * ((SELECT fldLF FROM #zArray) / 100))
IF (CAST((SELECT fldMF FROM #zArray) AS FLOAT) > '+@X+')
BEGIN
SET @X = (CAST((SELECT fldMF FROM #zArray) AS FLOAT))
END
END'
EXEC sp_executesql @SQL, N'@X NVARCHAR(50),@Z NVARCHAR(50)', @X, @Z
以下代码是否有问题会导致打印语句不起作用?
'SET @X = '+@Z+' * ((SELECT fldLF FROM #zArray) / 100))
IF (CAST((SELECT fldMF FROM #zArray) AS FLOAT) > '+@X+')
BEGIN
SET @X = (CAST((SELECT fldMF FROM #zArray) AS FLOAT))
END'