November 11, 2010 at 9:38 am
Hi,
I want to use two select queries in one view. The scenario is like, I will use result of one query as a join on another query. I can do this fine with temp tables.
But I want to achieve same stuff in View and it seems like view dont allow temp table.. Does anyone knows better way for this?
:rolleyes:
November 11, 2010 at 9:47 am
Subqueries, CTEs, or inline TVFs. Views need to be a single statement. Also remember views aren't encapsulated result sets unless you turn them into indexed views. Any time you call the view, you have to rerun the entire execution plan.
Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.
For better assistance in answering your questions[/url] | Forum Netiquette
For index/tuning help, follow these directions.[/url] |Tally Tables[/url]
Twitter: @AnyWayDBA
November 11, 2010 at 9:47 am
Views do not allow temp tables, but you can still use a derived table in the JOIN. Can you provide an example of what you are trying to do?
November 11, 2010 at 10:02 am
As John mentioned, more information and preferably code, would help.
I would learn towards a CTE if you have temp tables you are trying to use.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply