exec sp_executesql N'select top 51 when 6 then @StatusCode1 when 1 then @StatusCode2 ORDER BY incident0.TicketNumber desc
SQL you have posted will not compile as it's invalid - there is no FROM table mentioned and there is no closing quote at the end of sel string.
MAXDOP should be specified at the end of query you are executing as OPTION (MAXDOP 1)
So, your call should look like:
N'select top 51 when 6 then @StatusCode1 when 1 then @StatusCode2
ORDER BY incident0.TicketNumber desc OPTION (MAXDOP 1);',
"The only true wisdom is in knowing you know nothing"
"O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
(So many miracle inventions provided by MS to us...)How to post your question to get the best and quick help