0

I have problem. I need trigger after insert. But trigger have to insert few rows depends on select from other table.

is it possibe in sql?

Update:

ok, sorry.

Example (no-logic) tables: users(id,name,type_user) type_user(id,type) items(id,name,type_user) - some type of users can posses only few items users_items(id,item_id,user_id)

And when i insert into users i want to insert into users_items all items which user can posses

regisik
  • 19
  • 5
  • 1
    Can you give us a little more information, example, any code you have attempted, etc. That is a little vague. There is a loop in SQL (I am about to get ostricized for bringing it up), but there is very little good use for it. Maybe your specific situation will work but we need more info. – logixologist Dec 12 '13 at 18:25
  • Example (no-logic) tables: users(id,name,type_user) type_user(id,type) items(id,name,type_user) - some type of users can posses only few items users_items(id,item_id,user_id) And when i insert into users i want to insert into users_items all items which user can posses. – regisik Dec 12 '13 at 18:40
  • Please edit your question with this information instead of putting it in comments. – logixologist Dec 12 '13 at 18:50

1 Answers1

0

Yes it is possible. Inside SQL Triggers you can do Insert statements.

You can find SQL Trigger information here.

Try something like

CREATE TRIGGER RelateItems
ON User
AFTER INSERT
AS 
--INSERT STATEMENT HERE - INSERT INTO users_items 
GO