Thinking about the requirements:
- "quickly get access to the data without overloading the DB"
- "pull them what was made static [at] the time the view was created"
Especially the part about the data being static captured at a moment in time, I doubt a view is what you want. I think you may want something more like CDC, but that wasn't introduced until SQL Server 2008. For SQL Server 2005, a database snapshot may meet your needs.
Dominique's answer also potentially an option. There are multiple ways to fulfil above two requirements. Another example might be to create a stored procedure as shown below and schedule via SQL Server Agent. E.g. assuming source table:
CREATE TABLE SourceTable
(
C1 [datatype1] PRIMARY KEY
, C2 [datatype2]
, C3 [datatype3]
)
and a "Snapshot table" created to match:
CREATE TABLE SnapshotOfSourceTable
(
C1 [datatype1] PRIMARY KEY
, C2 [datatype2]
, C3 [datatype3]
)
then you could do something like this:
CREATE PROCEDURE dbo.UpdateSnapshotOfSourceTable
AS
BEGIN
BEGIN TRAN
BEGIN TRY
DELETE FROM SnapshotOfSourceTable
WHERE C1 NOT IN
(
SELECT C1
FROM SourceTable
)
UPDATE Snap
SET
Snap.C2 = Source.C2
, Snap.C3 = Source.C3
FROM SnapshotOfSourceTable [Snap]
INNER JOIN SourceTable [Source]
ON Snap.C1 = Source.C1
INSERT INTO SnapshotOfSourceTable
(C1, C2, C3)
SELECT C1, C2, C3
FROM SourceTable
WHERE C1 NOT IN
(
SELECT C1
FROM SnapshotOfSourceTable
)
COMMIT
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000);
DECLARE @ErrorSeverity INT;
DECLARE @ErrorState INT;
SELECT
@ErrorMessage = 'Error when attempting to update snapshot table from source: ' + ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE();
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
)
WITH LOG;
ROLLBACK
END CATCH
END
CREATE MATERIALIZED VIEWis invalid syntax in all versions of SQL Server so I an puzzled as to how you created the view with the DDL in your question. SQL Server indexed views are not static so you need a different approach, such as a table that is refreshed periodically or a view referencing a database snapshot.