Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A view represents a <strong>virtual</strong> table. You can join multiple tables in a view and use the view to present the data as if the data were coming from a single table.</p> <p>A stored procedure uses parameters to do a function... whether it is updating and inserting data, or returning single values or data sets.</p> <p><a href="https://msdn.microsoft.com/en-us/library/ms365311.aspx">Creating Views and Stored Procedures</a> - has some information from Microsoft as to when and why to use each.</p> <p>Say I have two tables:</p> <p>tbl_user Columns: .user_id, .user_name, .user_pw</p> <p>tbl_profile Columns: .profile_id, .user_id .profile_description</p> <p>So if i find myself querying from those tables ALOT... instead of doing the join in EVERY peice of sql i would define a view like:</p> <pre><code>CREATE View vw_user_profile AS Select A.user_id, B.profile_description FROM tbl_user A left join tbl_profile B on A.user_id = b.user_id GO </code></pre> <p>So in the future if i want to query profile_description by user id... all i have to do is</p> <pre><code>SELECT profile_description FROM vw_user_profile WHERE user_id = @ID </code></pre> <p>THAT code could be used in a stored procedure like:</p> <pre><code>create procedure dbo.getDesc @ID int AS begin SELECT profile_description FROM vw_user_profile WHERE user_id = @ID END GO </code></pre> <p>So later on i can call </p> <pre><code>dbo.getDesc 25 </code></pre> <p>and I will get the description for user id 25. where the 25 is your parameter.</p> <p>There is obviously A LOT more detail, but, this is just the basic idea.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload