Click here to Skip to main content
15,903,856 members
Home / Discussions / Database
   

Database

 
AnswerRe: Automatic primary key start in MS Access Pin
Eddy Vluggen23-May-09 8:13
professionalEddy Vluggen23-May-09 8:13 
QuestionHow to bypass TRIGGERs with no potential concurrency issues? Pin
Rafferty Uy21-May-09 16:34
Rafferty Uy21-May-09 16:34 
QuestionBest insert options. Pin
FISH78621-May-09 15:07
FISH78621-May-09 15:07 
AnswerRe: Best insert options. Pin
PIEBALDconsult21-May-09 15:57
mvePIEBALDconsult21-May-09 15:57 
GeneralRe: Best insert options. Pin
FISH78621-May-09 15:59
FISH78621-May-09 15:59 
GeneralRe: Best insert options. Pin
ISoftwareDev23-May-09 10:29
ISoftwareDev23-May-09 10:29 
AnswerRe: Best insert options. Pin
WoutL25-May-09 3:16
WoutL25-May-09 3:16 
QuestionTrigger in sql server 2005 [modified] Pin
beesan20-May-09 3:53
beesan20-May-09 3:53 
hi all,
i m trying to make a trigger for the database and i dont know how first where to write it?
and for example i make a master table and 3 other tables

Master_Table : will be in it all the actions

Table_1 : when insert a new record the max(ID) and the table name will be wriiten in the Master_Table

Table_2 : when update a record the (ID)of the updated record and the table name will be wriiten in the Master_Table

Table_3 : when delete a record the (ID)of the deleteded record and the table name will be wriiten in the Master_Table

i make this but it still gives me an error when execute but when i comment all of it except TriggerExInsert it works

CREATE TRIGGER TriggerExDelete<br />
   ON  Table_3 <br />
   AFTER DELETE<br />
AS <br />
BEGIN<br />
 -- SET NOCOUNT ON added to prevent extra result sets from<br />
 -- interfering with SELECT statements.<br />
 SET NOCOUNT ON;<br />
<br />
    INSERT INTO MasterTable(ID,ActionA)<br />
    SELECT ID, 'DELETE'<br />
    FROM deleted<br />
<br />
END<br />
GO<br />
<br />
CREATE TRIGGER TriggerExUpdate<br />
   ON  Table_2 <br />
   AFTER UPDATE<br />
AS <br />
BEGIN<br />
 -- SET NOCOUNT ON added to prevent extra result sets from<br />
 -- interfering with SELECT statements.<br />
 SET NOCOUNT ON;<br />
<br />
    INSERT INTO MasterTable(ID,ActionA)<br />
    SELECT ID, 'UPDATE'<br />
    FROM inserted<br />
<br />
END<br />
GO<br />
<br />
CREATE TRIGGER TriggerExInsert<br />
   ON  Table_1 <br />
   AFTER INSERT<br />
AS <br />
BEGIN<br />
 -- SET NOCOUNT ON added to prevent extra result sets from<br />
 -- interfering with SELECT statements.<br />
 SET NOCOUNT ON;<br />
<br />
    INSERT INTO MasterTable(ID,ActionA)<br />
    SELECT ID, 'INSERT'<br />
    FROM inserted<br />
<br />
END<br />
GO<br />
<br />



Thanx a lot for the help! Smile | :)

modified on Wednesday, May 20, 2009 10:10 AM

AnswerRe: Trigger in sql server 2005 Pin
Mycroft Holmes21-May-09 13:40
professionalMycroft Holmes21-May-09 13:40 
Questionminus operation Pin
hrishiS20-May-09 2:17
hrishiS20-May-09 2:17 
AnswerRe: minus operation Pin
Philip.F20-May-09 3:30
Philip.F20-May-09 3:30 
AnswerRe: minus operation Pin
PIEBALDconsult21-May-09 16:00
mvePIEBALDconsult21-May-09 16:00 
QuestionBest Traffic Campaign (2385) Pin
Faisal Halari20-May-09 0:36
Faisal Halari20-May-09 0:36 
AnswerRe: Best Traffic Campaign (2385) [As if you hadn't guessed, this is an ADVERT. IGNORE!!! Pin
Henry Minute20-May-09 0:39
Henry Minute20-May-09 0:39 
Questionproblem populating a combo box Pin
Jondo24shoots19-May-09 22:22
Jondo24shoots19-May-09 22:22 
AnswerRe: problem populating a combo box Pin
Henry Minute20-May-09 0:41
Henry Minute20-May-09 0:41 
AnswerRe: problem populating a combo box Pin
saanj28-May-09 3:12
saanj28-May-09 3:12 
QuestionMaking the local database to a remote database server Pin
Subin Alex19-May-09 20:14
Subin Alex19-May-09 20:14 
AnswerRe: Making the local database to a remote database server Pin
Mycroft Holmes19-May-09 23:22
professionalMycroft Holmes19-May-09 23:22 
QuestionLoading an array in a custom user function... [modified] Pin
new_phoenix19-May-09 14:59
new_phoenix19-May-09 14:59 
QuestionMessage Closed Pin
19-May-09 14:44
abbasi12319-May-09 14:44 
RantRe: Hiring home based workers (2718) Pin
Ashfield19-May-09 20:59
Ashfield19-May-09 20:59 
GeneralQuery based on Effective Date Pin
Brady Kelly19-May-09 4:20
Brady Kelly19-May-09 4:20 
GeneralRe: Query based on Effective Date Pin
David Mujica19-May-09 4:44
David Mujica19-May-09 4:44 
GeneralRe: Query based on Effective Date Pin
Brady Kelly19-May-09 5:00
Brady Kelly19-May-09 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.