Re: Using SQL username as criteria on a view

From: BP Margolin (bpmargo@attglobal.net)
Date: 05/29/02


From: "BP Margolin" <bpmargo@attglobal.net>
Date: Wed, 29 May 2002 14:53:09 -0400


Duncan,

Try something like:

select ...
from ...
where (Username = 'BOB' and States in ('MT', 'VA'))
or (Username = 'SALLY' and States in ('SC', 'DE'))

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.

"Duncan Isley" <divi@mindspring.com> wrote in message
news:943101c20721$fdbe5660$3aef2ecf@TKMSFTNGXA09...
> Ex)
> SQL username: BOB
> View called STATES, with fields of STATE and INVOICE
>
> Question,
> If this user is logging in via ODBC (MS Access) and I want
> him to only see records from the STATES view of MT and VA,
> but have the criteria driven off of the SQL LOGINNAME
> mapped thru (such that this crossmap table filters the
> records)
>
> Username STATES TO VIEW
> BOB MT
> BOB VA
> SALLY SC
> SALLY DE
>
> Such that I would only create 1 view, but have this login
> table handle the records s/he could query against.
>
> Thanks,
>
> Duncan