Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger wanted

Author  Topic 

messi
Starting Member

47 Posts

Posted - 2008-09-07 : 15:35:44
i created two tables in my database
i need when i add a number ex(10) to the first in a field
a trigger add 10 records to the second table

any
one know please help

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-07 : 15:54:55
http://msdn.microsoft.com/en-us/library/ms189799.aspx
Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-07 : 16:50:21
thanks for replaying
but can you give me the sql statement
because i couldn't figure out the statement by myself (i am a beginner)
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-08 : 03:00:27
quote:
Originally posted by messi

i created two tables in my database
i need when i add a number ex(10) to the first in a field
a trigger add 10 records to the second table

any
one know please help


Can you tell us what would be the 10 records for second table?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-08 : 10:22:40
i need when i add 10 to num field in table1 :



trigger add 10 records in table 2:

Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-08 : 17:12:16
i really need this trigger
please help...... this is my first question don't disappoint me
Go to Top of Page

lamujerdetuhermano10
Yak Posting Veteran

75 Posts

Posted - 2008-09-08 : 18:09:00
create TRIGGER addNumbers
ON computersca
AFTER INSERT
as
exec adds

------------------------

create proc adds as
declare @count int
set @count = 1
while @count < 11
begin
insert computersNV (computerid)
select @count
select @count = @count +1
end
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-09-08 : 18:40:25
and what happens when someone inserts 2000000000 into that column?


elsasoft.org
Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-08 : 18:49:43
Thank you very much it worked with me
Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-08 : 18:52:50
quote:
Originally posted by jezemine

and what happens when someone inserts 2000000000 into that column?


elsasoft.org



i just need the idea
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-09-08 : 19:01:50
you could improve on that trigger suggestion a lot by using a numbers table - then you wouldn't have a while loop. that while loop will kill your perf.


elsasoft.org
Go to Top of Page

messi
Starting Member

47 Posts

Posted - 2008-09-08 : 19:25:04
quote:
Originally posted by jezemine

you could improve on that trigger suggestion a lot by using a numbers table - then you wouldn't have a while loop. that while loop will kill your perf.


elsasoft.org



thanks for your replay
but what i can do in this trigger
( is there another way to make it)

Go to Top of Page
   

- Advertisement -