A
A
Anton Antonov2018-03-29 22:01:26
SQL Server
Anton Antonov, 2018-03-29 22:01:26

How to write a MS SQL trigger that adds a record to a table?

It is required to write a trigger to add 2 records to the ProductDetails table.
5abd37d9e91a4780934619.png"

create trigger qwe
on ProductDetails
for insert
as
if @@rowcount = 0
return
set nocount on 
update ProductDetails
set ID, Color, [Description]
from ProductDetails

I don't understand how to write it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Skorzhinsky, 2018-03-30
@default898953

Create trigger [mysterious trigger for a mysterious table]
on [mysterious table]
for delete, update, insert
as
begin
insert ProductDetails (id, Color, Description)
select top 2 id, 'Color', 'Description'
from Products
ebd

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question