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


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

Re: Indexing for View Containing UNION

Path csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups microsoft.public.sqlserver.programming
Subject Re: Indexing for View Containing UNION
Date Tue, 25 Jun 2019 21:05:39 +0200
Organization Erland Sommarskog
Lines 14
Message-ID <XnsAA79D694E407DYazorman@127.0.0.1> (permalink)
References <qeq08n$q9s$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252
Content-Transfer-Encoding 8bit
Injection-Info reader02.eternal-september.org; posting-host="43500eede1a6bf24270e6ff37baab807"; logging-data="20180"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+p00Y2Hoo0w2YfJFzQ5qt7"
User-Agent Xnews/2006.08.24 Mime-proxy/2.1.c.0 (Win32)
Cancel-Lock sha1:5JoxdvYTwVXPhBULi99vS4V/uss=
Xref csiph.com microsoft.public.sqlserver.programming:31349

Show key headers only | 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