-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreate All Possible Objects.sql
67 lines (57 loc) · 1.17 KB
/
Create All Possible Objects.sql
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
CREATE TABLE Parent
(
ParentID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED
);
GO
CREATE TABLE Child
(
ChildID INT PRIMARY KEY CLUSTERED,
ParentID INT FOREIGN KEY REFERENCES Parent(ParentID),
ChildName VARCHAR(100) UNIQUE NOT NULL,
DefaultColumn INT DEFAULT 10,
ComputedColumn AS (DefaultColumn / 2) -- This is a computed column
);
GO
CREATE VIEW vwTest AS
SELECT b.ParentID,
b.ChildID,
b.ChildName
FROM Parent a INNER JOIN
Child b ON a.ParentID = b.ParentID;
GO
CREATE VIEW vwTest2 WITH SCHEMABINDING AS
SELECT b.ParentID,
b.ChildID,
b.ChildName
FROM Parent a INNER JOIN
Child b ON a.ParentID = b.ParentID;
GO
CREATE PROCEDURE prTest1 AS
(
SELECT 'Hello World'
);
GO
CREATE FUNCTION fnScalar()
RETURNS INT
AS
BEGIN
RETURN 1
END;
GO
CREATE FUNCTION fnTable()
RETURNS @ResultTable TABLE (Number INT, Text VARCHAR(100))
AS
BEGIN
INSERT INTO @ResultTable (Number, Text) VALUES (1, 'Example');
RETURN;
END;
CREATE TYPE dbo.TypeTest FROM INTEGER NOT NULL;
GO
CREATE TYPE dbo.TypeTableTest AS TABLE
(
myValue INT,
myValue2 INT
);
GO
--CREATE A SEQUENCE
select * from sys.indexes;