473,791 Members | 2,985 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A few simple questions about SQL Server 'Views'

Hello,

I am building an application for Windows Forms using. I am new to SQL
Server 'Views'. Are the following correct understanding of their use?

1.) I believe a view can be referenced in a stored procedure something
like this;
Select * from View1
Is that true?

2.) I believe I can update to a view even when it includes two tables.
I intend to build a dataAdapter to a view for select and update. I
believe it can keep track of how to perform the update? Do I understand
its use correctly?

3.) Is it necessary to include both the the PK and FK when two tables
are part of the view or does it know the relationship established in
the database in the 'diagrams' area take care of that?

Thank you,
dbuchanan

Nov 23 '05 #1
2 1957
1) Yes
2) As long as you update only one of the member tables. That said, some
views are not updateable.
3) No

--
Tom

----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com

<db*********@ho tmail.com> wrote in message
news:11******** **************@ g49g2000cwa.goo glegroups.com.. .
Hello,

I am building an application for Windows Forms using. I am new to SQL
Server 'Views'. Are the following correct understanding of their use?

1.) I believe a view can be referenced in a stored procedure something
like this;
Select * from View1
Is that true?

2.) I believe I can update to a view even when it includes two tables.
I intend to build a dataAdapter to a view for select and update. I
believe it can keep track of how to perform the update? Do I understand
its use correctly?

3.) Is it necessary to include both the the PK and FK when two tables
are part of the view or does it know the relationship established in
the database in the 'diagrams' area take care of that?

Thank you,
dbuchanan

Nov 23 '05 #2
db*********@hot mail.com wrote:
Hello,

I am building an application for Windows Forms using. I am new to SQL
Server 'Views'. Are the following correct understanding of their use?

1.) I believe a view can be referenced in a stored procedure something
like this;
Select * from View1
Is that true?
Yes

2.) I believe I can update to a view even when it includes two tables.
I intend to build a dataAdapter to a view for select and update. I
believe it can keep track of how to perform the update? Do I understand
its use correctly?
Copy&Pasted from SQLServer Documentation:

Updatable Views
You can modify the data of an underlying base table through a view, as
long as the following conditions are true:

Any modifications, including UPDATE, INSERT, and DELETE statements, must
reference columns from only one base table.
The columns being modified in the view must directly reference the
underlying data in the table columns. The columns cannot be derived in
any other way, such as through the following:
An aggregate function: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV,
STDEVP, VAR, and VARP.
A computation. The column cannot be computed from an expression that
uses other columns. Columns that are formed by using the set operators
UNION, UNION ALL, CROSSJOIN, EXCEPT, and INTERSECT amount to a
computation and are also not updatable.
The columns being modified are not affected by GROUP BY, HAVING, or
DISTINCT clauses.
The previous restrictions apply to any subqueries in the FROM clause of
the view, just as they apply to the view itself. Generally, the Database
Engine must be able to unambiguously trace modifications from the view
definition to one base table. For more information, see Modifying Data
Through a View.

If the previous restrictions prevent you from modifying data directly
through a view, consider the following options:

INSTEAD OF Triggers

INSTEAD OF triggers can be created on a view to make a view updatable.
The INSTEAD OF trigger is executed instead of the data modification
statement on which the trigger is defined. This trigger lets the user
specify the set of actions that must happen to process the data
modification statement. Therefore, if an INSTEAD OF trigger exists for a
view on a specific data modification statement (INSERT, UPDATE, or
DELETE), the corresponding view is updatable through that statement. For
more information about INSTEAD OF triggers, see Designing INSTEAD OF
Triggers.
Partitioned Views

If the view is a partitioned view, the view is updatable, subject to
certain restrictions. When it is needed, the Database Engine
distinguishes local partitioned views as the views in which all
participating tables and the view are on the same instance of SQL
Server, and distributed partitioned views as the views in which at least
one of the tables in the view resides on a different or remote server.

For more information about partitioned views, see Creating Partitioned
Views.


3.) Is it necessary to include both the the PK and FK when two tables
are part of the view or does it know the relationship established in
the database in the 'diagrams' area take care of that?
You define Views in SQL... so you have to define the "join" that you
want to use.
Thank you,
dbuchanan

Nov 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
24918
by: Kofi | last post by:
I need just the names of tables, views and sprocs within a SQL Server database. What's the easiest way to do this?
5
1823
by: pete | last post by:
Today I need to copy 8 records in a table. I have to use Access 200 because of the limitation of Enterprise Manager's inability to cope with field with more than 900 characters. Selected records, cut, paste. I got an erroor message about not being able to have a null Key_ID (I copied the reords and tried to paste the Key_ID as part of the records - normally I hide the Key_ID). Now I can't access either the new records or the originals...
1
1200
by: John | last post by:
Hi I have a fairly complex access frontend/backend app which I need to upsize to SQL Server. At this stage I would prefer to use access as frontend. I have the following questions; 1. Should I keep using the mdb as frontend or switch to an adp (access project) instead? Any reasons? 2. I have used IIF (immediate if) frequently in access queries. When
8
1633
by: Old VB6 Guy | last post by:
First of all, sorry if crossposting bothers you -- I don't normally do it, but both of these groups seem relavant to my questions. Alright, the time has finally come to make an investment in time and money to jump start my career again. I am currently a VB6/ASP programmer, but worse yet, I am in a company that has me doing (yuch!) support work mostly and I get extremely limited programming "bones" thrown to me these days. In short, I...
4
1909
by: datapro01 | last post by:
Running DB28.2 on AIX 5.2. I have two questions if its possible for anyone to assist. 1. Is it possible to make use of a 'Shadow Catalog' on DB2 UDB v8.2 on AIX? If so, how? Can anyone give me an example of the SQL to create the appropriate view and catalog table? 2. Is there anyway via the ODBC datasource parameters to influence the SQLTables and SQLColumns stored procedures to use a schema_name when
5
1279
by: Newbie | last post by:
Hi all, Just want to comment on this thread. Seems like every discussion about this matter (setting up DB provider for membership) and all the samples/references given by some MVPs always refering to LOCALHOST in their solution. Aren't they all forget that people build an ASP.NET appl are plans to host their appl in an commercial hosting provider, whom most of them can't afford the fancy of dedicated servers - most of them hosts on shared...
30
15449
by: James Conrad StJohn Foreman | last post by:
After 3 years of using DB2 on Linux, I'm leaving my current employers to go work for a SQL Server shop instead. In order to find my replacement, they're trying to put together a set of questions to get both some understanding of how wide candidates knowledge is, and how much DB2 specifics they know. Of the questions below, how many do you think are useful in determining if you've got somebody capable of keeping a DB2 instance up,...
0
1029
by: Andy S. | last post by:
I'm not very knowledgeable using Visual Studio deployment projects, but I have 2 questions. 1. Can you perform SQL server database functions (i.e. Add views, stored procedures)? I overcame this obstical by writing an application to perform the SQL commands to create the views and stored procedures. I then added this as a step in the install custom actions, and this works fine. 2. Can you have it update just the files that change...
1
2271
by: TGEAR | last post by:
I am using MS SQL Server management studio. I treid to see some system tables which are sysobjects, syscolumns, systypes, etc.., but i don't see the list under the system tables folder. There is one table showing, sysdiagrams; however, I was able to query sql stmts though. where are they located? or Do I need to contact a dba to release those tables? thanks.
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.