SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 trigger wanted
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

messi
Starting Member

47 Posts

Posted - 09/07/2008 :  15:35:44  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Nigeria
2706 Posts

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

messi
Starting Member

47 Posts

Posted - 09/07/2008 :  16:50:21  Show Profile  Reply with Quote
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

India
22761 Posts

Posted - 09/08/2008 :  03:00:27  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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 - 09/08/2008 :  10:22:40  Show Profile  Reply with Quote
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 - 09/08/2008 :  17:12:16  Show Profile  Reply with Quote
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 - 09/08/2008 :  18:09:00  Show Profile  Reply with Quote
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

Edited by - lamujerdetuhermano10 on 09/08/2008 18:10:09
Go to Top of Page

jezemine
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 09/08/2008 :  18:40:25  Show Profile  Visit jezemine's Homepage  Reply with Quote
and what happens when someone inserts 2000000000 into that column?


elsasoft.org
Go to Top of Page

messi
Starting Member

47 Posts

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

messi
Starting Member

47 Posts

Posted - 09/08/2008 :  18:52:50  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

USA
2886 Posts

Posted - 09/08/2008 :  19:01:50  Show Profile  Visit jezemine's Homepage  Reply with Quote
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 - 09/08/2008 :  19:25:04  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.1 seconds. Powered By: Snitz Forums 2000