到目前为止,对于初学者来说,我是一个人来的,但我不明白我哪里出错了

With Procedure for a beginner so far i've come alone but i can't understand where i'm going wrong

如何解决?这个想法是立即插入 table 人的记录,phone 和地址,但每个记录都有其数据并尊重 table 人中复制的身份创建的 ID该领域的其他人 people_id

Create Procedure newRegister
(
    @PeopleID int,
    @Name nvarchar(100),
    @Phone numeric(9),
    @Adress nvarchar(150),
    @NumLocal numeric(5),
    @Type_Fone nvarchar(20),
    @CodeArea numeric (3)
)

AS 

begin
INSERT INTO people values (@Name, @Phone,@Adress)
INSERT INTO adress values (@Adress,@PeopleID)
INSERT INTO phones values (@Phone,@CodeArea,@Type_Fone,@PeopleID)
end

执行:

exec newRegister @PeopleID = 1, @Name = "Victor", @Phone = 111222333, @Adress = 'Northen Street 55', @NumLocal = 155, @Type_Fone = 'Mobile', @CodeArea = 100

执行后只有table这个人收到数据,地址table有外键违规错误,phonetable也有同样的错误错误。 并且未输入数据。

我的 table 人

CREATE TABLE people (
    id int IDENTITY(1,1) NOT NULL,
    name nvarchar(150) NOT NULL,
    adress nvarchar(150) NOT NULL,
    phone numeric(9) NOT NULL,
    PRIMARY KEY (id)
);

我的tablephone:

CREATE TABLE phone (
    id int IDENTITY(1,1) NOT NULL,
    phone numeric(9) NOT NULL,
    codearea numeric(3) NOT NULL,
    type_fone nvarchar(20) NOT NULL,
    people_id int NOT NULL
    PRIMARY KEY (id),
     CONSTRAINT FK_phone_people FOREIGN KEY (people_id)
    REFERENCES people(id)
);

我的table地址:

CREATE TABLE adress (
    id int IDENTITY(1,1) NOT NULL,
    adress nvarchar(150) NOT NULL,
    numlocal numeric(5) NOT NULL,
    people_id int NOT NULL,
    PRIMARY KEY (id),
     CONSTRAINT FK_adress FOREIGN KEY (people_id)
    REFERENCES people(id)
);

您必须指定字段

来自

begin
INSERT INTO people values (@Name, @Phone,@Adress)
INSERT INTO adress values (@Adress,@PeopleID)
INSERT INTO phones values (@Phone,@CodeArea,@Type_Fone,@PeopleID)
end

--Example, btw address, not adress if You are going for English
INSERT INTO PEOPLE(name, phone, adress)
VALUES(@Name, @Phone,@Adress)