Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Hint recompile to inner query

$
0
0

If i have sql statement(which is inside dynamic sql) like this:

DECLARE @myId int

SET @myId=(SELECT TOP 1 myId FROM myTable WHERE myName='myName')

The plan for this query is always cached, I have checked.
How can I add hint OPTION (RECOMPILE) to this statement to prevent caching?

I have tried everything and it won't work:

br, Simon



Viewing all articles
Browse latest Browse all 23857

Trending Articles