I wrote a query in this format..
Select * INTO #xyz FROM ()
which I later want to use to create a view, as…
CREATE VIEW aaa
AS
Select * INTO #xyz FROM ()
but getting the following errors:
- Incorrect syntax near the keyword ‘INTO’.
- Views or functions are not allowed on temporary tables
Can someone please suggest a workaround this? Is it possible to use temporary tables to create views?
You certainly cannot use a select into in a view. And a termp table is not approraite either. Use a derived table that is the equivalent of the temp table instead. Example:
Suppose you had:
Then you could use:
You could also usea a CTE