A serious error occurred in the current team. - Unknown error

This is my code.

;With CTE as
(
select
    a.rn,
    a.LongDescription as ad,
    b.LongDescription as bd
from myTabl as a
    left join myTabl as b on a.rn +1 = b.rn
where
    a.rn=1
and
    a.LongDescription = 'Eric'
)
update CTE
    set ad += ' ' + b.LongDescription
from CTE as a
    left join myTabl as b on a.rn = b.rn+1
where
    a.rn=1

I tried to answer one question, trying to figure it out. options I encountered the following error,

Msg 0, Level 11, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.
Msg 0, Level 20, State 0, Line 0
A severe error occurred on the current command.  The results, if any, should be discarded.

What is it, I get nothing. Is there any serious bug in my code? I tried to do this, but all the results redirect me to "Microsoft Fix". Can someone explain to me in simple words that WHAT IS WRONG?

+4
source share
2 answers

I think you need to change the given line:

set ad = a.ad + ' ' + b.LongDescription

Check out the SQL script demo here

0
source

TRY IT.................

;With CTE as
(
select
    a.rn,
    a.LongDescription as ad,
    b.LongDescription as bd
from myTabl as a
    left join myTabl as b on a.rn +1 = b.rn
where
    a.rn=1
and
    a.LongDescription = 'Eric'
)
update CTE
    set ad += ' ' + b.LongDescription
from CTE as a
    left join 
    ( select (rn+1) AS NewRN,* from myTabl )as b on a.rn = b.NewRN
where
    a.rn=1
0
source

Source: https://habr.com/ru/post/1534442/


All Articles