Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Indexes on Views - with UNION

$
0
0
Hi Team,Want to create a view using below query, and also want to apply indexes on that view.[quote]SELECT NT.ID, U.acc_name FROM dbo.NR_VT NT WITH (NOLOCK), dbo.ACCOUNTS U WITH (NOLOCK)WHERE NT.VT = U.acc_nameUNION SELECT NT.ID, U.acc_name FROM dbo.NR_VT NT WITH (NOLOCK), dbo.ACCOUNTS U WITH (NOLOCK), dbo.Wat_GRP SG WITH (NOLOCK)WHERE U.acc_name = SG.acc_name AND NT.VT = CONVERT(NVARCHAR(150), SG.Wat_GRP_ID);[/quote][b]while creating indexes on view getting below error[/b]Cannot create index on view because it contains one or more UNION, INTERSECT, or EXCEPT operators. Consider creating a separate indexed view for each query that is an input to theUNION, INTERSECT, or EXCEPT operators of the original view.

Viewing all articles
Browse latest Browse all 3145

Trending Articles