Хочу создать триггер который будет автоматически подвязывать поле Id
, из таблицы
users
, с UserID
из таблицы profiles
Вот код на T-SQL :
create table users (
Id int not null primary key identity,
Username varchar(30) not null unique,
Email varchar(30) not null unique,
);
create table profiles (
Id int primary key identity,
UserId int not null references users(Id) ,
Name varchar(30) not null,
);
go
create trigger new_profile on users after insert as
for each row
begin
insert into profiles(UserId) values (new.Id);
end
Главная ошибка возле for each row
, где при создании триггера получаю такую ошибку :
Incorrect syntax near the keyword 'for'.
Не могли бы вы помочь с решением проблемы , спасибо!