Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.sqlserver.programming > #31349

Re: Indexing for View Containing UNION

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups microsoft.public.sqlserver.programming
Subject Re: Indexing for View Containing UNION
Date 2019-06-25 21:05 +0200
Organization Erland Sommarskog
Message-ID <XnsAA79D694E407DYazorman@127.0.0.1> (permalink)
References <qeq08n$q9s$1@dont-email.me>

Show all headers | View raw


Michael Cole (micheal.cole@invalid.com) writes:
> The intent is "C" is not an actual owner - that all the records with 
> "C" as their owner are effectively shared for all other owners, and 
> this we need to ensure uniqueness of ownership based on the query in 
> the view, e.g., any "owned" items can not be the same as a "shared" 
> item.  Issue is that I cannot put a PK on the view as it contains the 
> UNION.I cannot change the data structure, but any suggestions as to how 
> I could implement such a constraint would be welcome.
> 

Not only is the UNION preventing you indexed view, the subquery does too, 
and I don't thinkt the CROSS APPLY is good.

I think you will need to use triggers to enforce this.

Back to microsoft.public.sqlserver.programming | Previous | NextPrevious in thread | Find similar


Thread

Indexing for View Containing UNION Michael Cole <micheal.cole@invalid.com> - 2019-06-24 18:05 +1000
  Re: Indexing for View Containing UNION Erland Sommarskog <esquel@sommarskog.se> - 2019-06-25 21:05 +0200

csiph-web