Sql server random slow query

@mdsantos - An alternative way of getting the execution plans is to get them from the cache, it's not an ideal method. http://www.sqlserver-dba.com/2011/01/sql-server-query-plans-in-cache.html

You are better off , running the query in SSMS and savin the execution plan.

Based on your earlier comment you are getting a 701 message , internal memory pressure - find details here on how to troubleshoot this type of memory pressure http://www.sqlserver-dba.com/2013/07/troubleshoot-error-701-there-is-insufficient-system-memory-to-run-this-query.html