CREATE TABLE Person
(
ID INT Primary Key Identity (1,1),
LastName nVarchar (20) not NULL,
FirstName nVarchar (20) not NULL,
MiddleName nVarchar (20),
BirthDate DateTime not NULL,
Age INT not NULL,
Check (Age>18)
);
CREATE TABLE Department
(
ID INT Primary Key Identity (1,1),
DepartmentName nVarchar (50) Unique,
DepartmentCode nVarchar (20) Unique,
IsActive Bit Default (1)
);
CREATE TABLE Employee
(
ID INT Primary Key Identity (1,1),
PersonId INT Foreign Key REFERENCES Person,
DepartmentId INT Foreign Key REFERENCES Department,
Salary Decimal (18,2),
Check (Salary>10000),
IsActive Bit Default (1)
);
これを使用してみましたが、これが正しいかどうかはよくわかりません。
CREATE PROCEDURE sp_retrieve
AS
BEGIN
SELECT * FROM Person
END
GO
検索、更新、および削除のためのストアド プロシージャを正しく作成するにはどうすればよいですか?