View from a table

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    View from a table

    Hi

    Complete newbie to sql server. I have a Companies table from which I would
    like to create a Clients view as follows;

    SELECT ID, Company, CompanyType
    FROM dbo.Companies
    WHERE (CompanyType = N'Client')

    Such that when I insert a record into this view it automatically sets
    Company Type to Client. Just so I can treat the view as just another table
    without having to worry about setting the correct company type. Is there a
    way to do this either via views or some other way?

    Thanks

    Regards


  • Erland Sommarskog

    #2
    Re: View from a table

    John (John@nospam.in fovis.co.uk) writes:[color=blue]
    > Complete newbie to sql server. I have a Companies table from which I would
    > like to create a Clients view as follows;
    >
    > SELECT ID, Company, CompanyType
    > FROM dbo.Companies
    > WHERE (CompanyType = N'Client')
    >
    > Such that when I insert a record into this view it automatically sets
    > Company Type to Client. Just so I can treat the view as just another table
    > without having to worry about setting the correct company type. Is there a
    > way to do this either via views or some other way?[/color]

    The main venue for this thread is microsoft.publi c.sqlserver.ser ver. I
    post this thread here, so that readers of this group do not waste
    their time on John.


    --
    Erland Sommarskog, SQL Server MVP, esquel@sommarsk og.se

    Books Online for SQL Server SP3 at
    Get the flexibility you need to use integrated solutions, apps, and innovations in technology with your data, wherever it lives—in the cloud, on-premises, or at the edge.


    Comment

    Working...