1

I have the following SQL Query. There is a lot more happening (basically a lot of conditional statements adding to the end of these variables) but I tried to simplify it just because I want to know if it is related to the order

 DECLARE @sql NVARCHAR(MAX)
 DECLARE @tempTableBuild NVARCHAR(MAX)
 DECLARE @insertTempTableBuild NVARCHAR(MAX)

 SET @sql = N'a very very long query...';
 SET @tempTableBuild = N'DECLARE @results table
        (
            Index1 INT,
            Index2 INT,
            Index3 INT
 )'
 SET @insertTempTableBuild = N'INSERT INTO @results
            (
                Index1,
                Index2,
                Index3
 )'

 DECLARE @lastSQL NVARCHAR(MAX)
 SET @lastSQL = @tempTableBuild
 SET @lastSQL += @insertTempTableBuild
 SET @lastSQL += @sql

Why is my @lastSQL variable getting chopped? Is it because they should be in a certain order? Or is it not related to the order at all?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AleAng
  • 71
  • 1
  • 9
  • 2
    your answer is [here](http://stackoverflow.com/questions/12639948/sql-nvarchar-and-varchar-limits) – cha Oct 12 '16 at 00:29

0 Answers0