Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


sp_executesql MAXDOP


sp_executesql MAXDOP

Author
Message
david.alcock
david.alcock
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 1161
Just trying to test the affect of MAXDOP = 1 inside a query executed by sp_executesql within CRM. The query itself has lots of variables, so takes a similar form to the below, (excuse the copying and pasting):

exec sp_executesql N'select top 51 when 6 then @StatusCode1 when 1 then @StatusCode2 ORDER BY incident0.TicketNumber desc
@StatusCode1=N'Canceled',@StatusCode2=N'In Progress'

My question really is this, where to put the OPTION MAXDOP(1) command, I put it right at the end but its seemingly ignored?

Many thanks!

'Only he who wanders finds new paths'
Eugene Elutin
Eugene Elutin
Hall of Fame
Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)Hall of Fame (3K reputation)

Group: General Forum Members
Points: 3046 Visits: 5478
...
exec sp_executesql N'select top 51 when 6 then @StatusCode1 when 1 then @StatusCode2 ORDER BY incident0.TicketNumber desc
@StatusCode1=N'Canceled',@StatusCode2=N'In Progress'


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:


exec sp_executesql
N'select top 51 when 6 then @StatusCode1 when 1 then @StatusCode2
FROM incident0
ORDER BY incident0.TicketNumber desc OPTION (MAXDOP 1);',
@StatusCode1=N'Canceled',@StatusCode2=N'In Progress'



_____________________________________________
"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
david.alcock
david.alcock
SSC Veteran
SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)SSC Veteran (261 reputation)

Group: General Forum Members
Points: 261 Visits: 1161
Apologies for the rather hasty copy and paste snippets that weren't exactly workable and thank you for the reply. The query is rather mammoth in size and I was having difficulty cutting out the sensitive information parts so thought I would take a punt!

However, the example you provided was spot on, thank you very much! :-)

'Only he who wanders finds new paths'
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search