Due to SQL limitation to varchar(8000) for local variables, I am trying to using a Temp Table to break the values into three varchar (8000). I would like to use another TEMP table in the code below, so @body can be TEXT and allocate the @body value into three varchar (8000) variable so I can use at ######. Any suggestions on how I can do this?
Current Code Is:
DECLARE @body VARCHAR(8000) --need to change this
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #TempTable (...)
SELECT (...)
SELECT @body = ...
FROM #TempTable
ORDER BY ID
--add to @body
SET @body = (...)
Truncate table #TempTable
FETCH NEXT FROM ...
######
Current Code Is:
DECLARE @body VARCHAR(8000) --need to change this
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO #TempTable (...)
SELECT (...)
SELECT @body = ...
FROM #TempTable
ORDER BY ID
--add to @body
SET @body = (...)
Truncate table #TempTable
FETCH NEXT FROM ...
######