I want to limit the number of records returned by calling ROW_NUMBER(), but I am curious as to if you can call it in dynamic sql?
Also, Can you use CTE's in dynamic sql?
I want to limit the number of records returned by calling ROW_NUMBER(), but I am curious as to if you can call it in dynamic sql?
Also, Can you use CTE's in dynamic sql?
Do you mean, as opposed to being called from inside a stored procedure or other code object? If that's the question, the answer is yes. Note for the record that row_number is only supported on SQL 2005 and later.