MohitPandit
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
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
Instead of using 10 different tables use one partitioned table.
ASKER
But for now, we have to make it separate 10 tables.
Could you please assist best optimal solutions using this design for now?
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
...
CREATE VIEW ... AS
SELECT ...
FROM dbo.table1
WHERE ...
UNION ALL
SELECT ...
FROM dbo.table2
WHERE ...
UNION ALL
...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks