1.i Declare it like this:
declare @sql6 nvarchar(max)=''
--RETURN
SET @defs = N'
@groupCode VARCHAR(128),
@zScore float=''.95''';
set @sql6=@sql6+'BUNCH OF CODE >8000'
PRINT CAST(@SQL6 AS NTEXT)
EXEC sp_executesql @SQL6, @defs,
@GroupCode = @GroupCode,
@zScore = @zScore
Should the statement PRINT CAST(@SQL6 AS NTEXT) print an unlimited amount of characters?
My code has a syntax error in the following:
the print statement prints:
SELECT
P.SourceCode,
P.TreatmentID,
P.ProductID,
P.OptimizationGroupID,
P.TreatmentOrdinal,
CASE WHEN P.PricingType = 'Treatment' THEN 'Treatment 0' ELSE P.PricingType END PricingType,
COALESCE(QuantityLooks, 0) AS QuantityLooks, --n
COALESCE(LooksPercentag
and the errror statement says:
Msg 102, Level 15, State 1, Line 350
Incorrect syntax near 'LooksPercentag'.
So it seems the dynamic sql is getting cut off there.
From my previous research I had thought my code could be basically unlimited in length (less than 2^31 bytes or something) if I did the set @sql6=@sql6+'BUNCH OF CODE >8000'
Am I missing something?