Link to home
Start Free TrialLog in
Avatar of MohitPandit
MohitPanditFlag for India

asked on

SQL Server 2012: Materialized View (Indexed View)

Hello Folks,

I've 10 different tables with same table design (i.e. fields).
I would like to create a script for complex logic. So, I wanted to create an Indexed View with UNION for all tables and use that view in complex logic.
But UNION does not allow in Indexed View.

Do you have any thoughts for best way to do that?
Like, I've one thought that I create a temp table in complex logic and store all data in temp table from 10 different tables.
Actually, one table contains around 1 Million records.

I am looking forward response.

Best Regards,
Mohit Pandit
Avatar of ste5an
ste5an
Flag of Germany image

Instead of using 10 different tables use one partitioned table.
Avatar of MohitPandit

ASKER

But for now, we have to make it separate 10 tables.
Could you please assist best optimal solutions using this design for now?
You can use a standard view.  As long as the tables are properly indexed, it should perform OK.

CREATE VIEW ... AS
SELECT ...
FROM dbo.table1
WHERE ...
UNION ALL
SELECT ...
FROM dbo.table2
WHERE ...
UNION ALL
...
ASKER CERTIFIED SOLUTION
Avatar of Randy Knight, MCM
Randy Knight, MCM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks