-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSCALAR_Function.sql
More file actions
40 lines (35 loc) · 869 Bytes
/
SCALAR_Function.sql
File metadata and controls
40 lines (35 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
Functions: Reusable Logic
Scalar Values: Returns a single value back to the caller
Tables:
- Table-Valued User-defined-function
- Single line of code is called inline table-valued UDG
- Multiple lines of code is called multi-statement table-valued UDF
- Returns a table
- Can appear in the FROM clause of a query
- Used as a table
- NOTE: Cannot
- Apply Schema or data changes in the database
- Create or access temp tables
- Call a stored procedure
- Execute dynamic SQL
*/
--SELECT
-- COUNT(Freight) Nbr,
-- SUM(Freight) 'Avg'
--FROM
-- sales.SalesOrderHeader
--SELECT *
--FROM Sales.SalesOrderHeader
--CREATE FUNCTION TandF(
-- @tax money,
-- @freight money
--)
--RETURNS INT
--AS
--BEGIN
-- RETURN @tax + @freight
--END
SELECT SalesOrderID, dbo.TandF(TaxAmt, Freight) 'Tax/Freight'
FROM
Sales.SalesOrderHeader