SQL - 2071B 09
SQL - 2071B 09
to Programming Objects
Overview
title
title_no title author synopsis
1 Last of the MohicansJames Fenimore Cooper~~~
2 The Village Watch-Tower
Kate Douglas Wiggin ~~~
3 Poems Wilfred Owen ~~~
USE library
GO
CREATE VIEW dbo.TitleView
AS
SELECT title, author
FROM title
GO
TitleView
title author
Last of the Mohicans James Fenimore Cooper User’s View
The Village Watch-Tower
Kate Douglas Wiggin
Poems Wilfred Owen
Advantages of Views
Defining Views
Restrictions on Creating Views
Example: Viewing Information from
Multiple Tables
Defining Views
USE library
GO
CREATE VIEW dbo.birthdayview BirthdayV
(lastname, firstname, birthday) iew Birth Date
lastnamefirstname
AS
SELECT lastname, firstname Thomas Gary 92.01.16
Funk Frank 84.01.18
,CONVERT(char(8), birth_date, 2)
FROM member
INNER JOIN juvenile
ON member.member_no = juvenile.member_no
GO
Introduction to Stored Procedures
Scalar Functions
Similar to a built-in function
Returns a single data value built by a series of
statements
Multi-Statement Table-valued Functions
Content like a stored procedure
Referenced like a view
In-line Table-valued Functions
Similar to a view with parameters
Returns a table as the result of single SELECT
statement
Creating a User-defined Function
RETURN @myinput
END
GO
Restrictions on User-defined Functions
Recommended Practices