Trigger exists but is not showing up in Trigger folder under Server Objects, Database Triggers, or Table
I have looked at these threads and while they are similar, they do not answer my question.
Can't see the triggers that I created in SQL Server Management Studio 2008
Unable to find where triggers are stored in sql server 2008
Where does a Server trigger save in SQL Server?
In SSMS 17.9.1 (SQL Server 2017), I can see the trigger exists when using this code
select * from FocalAreas.sys.triggers
I can also see on the SharingPermissionTest (table where I want the trigger) > View Dependencies, the trigger is there. However, when I expand the SharingPermissionTest trigger folder, there is nothing there. When I expand the Programmability > Database Triggers on the database there is nothing there. When I expand the Server Objects > Triggers there is nothing there. Anybody have any insight into what's going on? This was my SQL to create the trigger:
USE FocalAreas
GO
CREATE TRIGGER dbo.SharingPermissionsTrigger
ON FocalAreas.dbo.FOCALREFERENCEAREAS
AFTER INSERT
AS BEGIN
DECLARE @FocalRefID nvarchar(50)
DECLARE @StateID nvarchar(2)
SELECT @FocalRefID = i.FocalRefID
FROM Inserted i
WHERE 1=1
SELECT @StateID = mp.StateID
FROM Inserted i, FocalAreas.dbo.MonitoringPoint as mp
WHERE i.FocalRefID = mp.FocalRefID
INSERT INTO FocalAreas.dbo.SharingPermissionsTest
Values
(next value for SharingPermissionSequence, @FocalRefID, 'NBTC', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'StateWildlifeAgency', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'FedPartners', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'NGO', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'Public', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed')
END
GO

add a comment |
I have looked at these threads and while they are similar, they do not answer my question.
Can't see the triggers that I created in SQL Server Management Studio 2008
Unable to find where triggers are stored in sql server 2008
Where does a Server trigger save in SQL Server?
In SSMS 17.9.1 (SQL Server 2017), I can see the trigger exists when using this code
select * from FocalAreas.sys.triggers
I can also see on the SharingPermissionTest (table where I want the trigger) > View Dependencies, the trigger is there. However, when I expand the SharingPermissionTest trigger folder, there is nothing there. When I expand the Programmability > Database Triggers on the database there is nothing there. When I expand the Server Objects > Triggers there is nothing there. Anybody have any insight into what's going on? This was my SQL to create the trigger:
USE FocalAreas
GO
CREATE TRIGGER dbo.SharingPermissionsTrigger
ON FocalAreas.dbo.FOCALREFERENCEAREAS
AFTER INSERT
AS BEGIN
DECLARE @FocalRefID nvarchar(50)
DECLARE @StateID nvarchar(2)
SELECT @FocalRefID = i.FocalRefID
FROM Inserted i
WHERE 1=1
SELECT @StateID = mp.StateID
FROM Inserted i, FocalAreas.dbo.MonitoringPoint as mp
WHERE i.FocalRefID = mp.FocalRefID
INSERT INTO FocalAreas.dbo.SharingPermissionsTest
Values
(next value for SharingPermissionSequence, @FocalRefID, 'NBTC', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'StateWildlifeAgency', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'FedPartners', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'NGO', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'Public', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed')
END
GO

1
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if yourINSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and theInserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select fromInserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!
– marc_s
Jan 2 at 19:05
2
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSIJOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged
– marc_s
Jan 2 at 19:05
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
1
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25
add a comment |
I have looked at these threads and while they are similar, they do not answer my question.
Can't see the triggers that I created in SQL Server Management Studio 2008
Unable to find where triggers are stored in sql server 2008
Where does a Server trigger save in SQL Server?
In SSMS 17.9.1 (SQL Server 2017), I can see the trigger exists when using this code
select * from FocalAreas.sys.triggers
I can also see on the SharingPermissionTest (table where I want the trigger) > View Dependencies, the trigger is there. However, when I expand the SharingPermissionTest trigger folder, there is nothing there. When I expand the Programmability > Database Triggers on the database there is nothing there. When I expand the Server Objects > Triggers there is nothing there. Anybody have any insight into what's going on? This was my SQL to create the trigger:
USE FocalAreas
GO
CREATE TRIGGER dbo.SharingPermissionsTrigger
ON FocalAreas.dbo.FOCALREFERENCEAREAS
AFTER INSERT
AS BEGIN
DECLARE @FocalRefID nvarchar(50)
DECLARE @StateID nvarchar(2)
SELECT @FocalRefID = i.FocalRefID
FROM Inserted i
WHERE 1=1
SELECT @StateID = mp.StateID
FROM Inserted i, FocalAreas.dbo.MonitoringPoint as mp
WHERE i.FocalRefID = mp.FocalRefID
INSERT INTO FocalAreas.dbo.SharingPermissionsTest
Values
(next value for SharingPermissionSequence, @FocalRefID, 'NBTC', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'StateWildlifeAgency', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'FedPartners', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'NGO', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'Public', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed')
END
GO

I have looked at these threads and while they are similar, they do not answer my question.
Can't see the triggers that I created in SQL Server Management Studio 2008
Unable to find where triggers are stored in sql server 2008
Where does a Server trigger save in SQL Server?
In SSMS 17.9.1 (SQL Server 2017), I can see the trigger exists when using this code
select * from FocalAreas.sys.triggers
I can also see on the SharingPermissionTest (table where I want the trigger) > View Dependencies, the trigger is there. However, when I expand the SharingPermissionTest trigger folder, there is nothing there. When I expand the Programmability > Database Triggers on the database there is nothing there. When I expand the Server Objects > Triggers there is nothing there. Anybody have any insight into what's going on? This was my SQL to create the trigger:
USE FocalAreas
GO
CREATE TRIGGER dbo.SharingPermissionsTrigger
ON FocalAreas.dbo.FOCALREFERENCEAREAS
AFTER INSERT
AS BEGIN
DECLARE @FocalRefID nvarchar(50)
DECLARE @StateID nvarchar(2)
SELECT @FocalRefID = i.FocalRefID
FROM Inserted i
WHERE 1=1
SELECT @StateID = mp.StateID
FROM Inserted i, FocalAreas.dbo.MonitoringPoint as mp
WHERE i.FocalRefID = mp.FocalRefID
INSERT INTO FocalAreas.dbo.SharingPermissionsTest
Values
(next value for SharingPermissionSequence, @FocalRefID, 'NBTC', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'StateWildlifeAgency', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'FedPartners', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'NGO', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed'),
(next value for SharingPermissionSequence, @FocalRefID, 'Public', @StateID,
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed',
'Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed','Not Allowed'
,'Not Allowed')
END
GO


asked Jan 2 at 18:51
MKFMKF
18111
18111
1
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if yourINSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and theInserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select fromInserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!
– marc_s
Jan 2 at 19:05
2
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSIJOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged
– marc_s
Jan 2 at 19:05
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
1
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25
add a comment |
1
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if yourINSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and theInserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select fromInserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!
– marc_s
Jan 2 at 19:05
2
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSIJOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged
– marc_s
Jan 2 at 19:05
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
1
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25
1
1
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if your
INSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and the Inserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select from Inserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!– marc_s
Jan 2 at 19:05
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if your
INSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and the Inserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select from Inserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!– marc_s
Jan 2 at 19:05
2
2
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSI
JOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged– marc_s
Jan 2 at 19:05
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSI
JOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged– marc_s
Jan 2 at 19:05
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
1
1
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25
add a comment |
1 Answer
1
active
oldest
votes
Expand the tree for the TABLE FocalAreas.dbo.FOCALREFERENCEAREAS
, right click on the "Triggers" node/folder, click "Refresh", then expand the "Triggers" tree. The trigger should be there.
This is the solution from the first link you posted, by the way, but in the text of your question, you don't describe following this solution correctly. You mention "when I expand the SharingPermissionTest trigger folder, there is nothing there." but you never mention looking under the actual table that the trigger is on, which is what the answer in the linked question tells you to do.
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011647%2ftrigger-exists-but-is-not-showing-up-in-trigger-folder-under-server-objects-dat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Expand the tree for the TABLE FocalAreas.dbo.FOCALREFERENCEAREAS
, right click on the "Triggers" node/folder, click "Refresh", then expand the "Triggers" tree. The trigger should be there.
This is the solution from the first link you posted, by the way, but in the text of your question, you don't describe following this solution correctly. You mention "when I expand the SharingPermissionTest trigger folder, there is nothing there." but you never mention looking under the actual table that the trigger is on, which is what the answer in the linked question tells you to do.
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
add a comment |
Expand the tree for the TABLE FocalAreas.dbo.FOCALREFERENCEAREAS
, right click on the "Triggers" node/folder, click "Refresh", then expand the "Triggers" tree. The trigger should be there.
This is the solution from the first link you posted, by the way, but in the text of your question, you don't describe following this solution correctly. You mention "when I expand the SharingPermissionTest trigger folder, there is nothing there." but you never mention looking under the actual table that the trigger is on, which is what the answer in the linked question tells you to do.
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
add a comment |
Expand the tree for the TABLE FocalAreas.dbo.FOCALREFERENCEAREAS
, right click on the "Triggers" node/folder, click "Refresh", then expand the "Triggers" tree. The trigger should be there.
This is the solution from the first link you posted, by the way, but in the text of your question, you don't describe following this solution correctly. You mention "when I expand the SharingPermissionTest trigger folder, there is nothing there." but you never mention looking under the actual table that the trigger is on, which is what the answer in the linked question tells you to do.
Expand the tree for the TABLE FocalAreas.dbo.FOCALREFERENCEAREAS
, right click on the "Triggers" node/folder, click "Refresh", then expand the "Triggers" tree. The trigger should be there.
This is the solution from the first link you posted, by the way, but in the text of your question, you don't describe following this solution correctly. You mention "when I expand the SharingPermissionTest trigger folder, there is nothing there." but you never mention looking under the actual table that the trigger is on, which is what the answer in the linked question tells you to do.
answered Jan 2 at 18:57
Tab AllemanTab Alleman
27.5k62442
27.5k62442
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
add a comment |
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
Thanks, I did not understand it would make the trigger on FocalReferenceAreas (this is my first time making a trigger). I thought the ON FOCALREFERENCEAREAS would mean when I inserted a row there, then it would insert all the other stuff into SharingPermissionsTest. I will edit my trigger SQL.
– MKF
Jan 2 at 19:05
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
That IS what it means. But in SSMS, you will find the trigger under the table that it is ON. Not under the table(s) that the code might reference.
– Tab Alleman
Jan 2 at 19:08
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
Thanks for the clarification! Really appreciate it.
– MKF
Jan 2 at 19:12
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54011647%2ftrigger-exists-but-is-not-showing-up-in-trigger-folder-under-server-objects-dat%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Your trigger has MAJOR flaw in that you seem to assume it'll be called once per row - that is not the case. The trigger will fire once per statement, so if your
INSERT
that causes this trigger to fire inserts 25 rows, you'll get the trigger fired once and theInserted
pseudo table will contain 25 rows. Which of those 25 rows will your code select fromInserted
? It's non-deterministic, you'll get one arbitrary row and you will be ignoring all other rows. You need to rewrite your trigger to take this into account!– marc_s
Jan 2 at 19:05
2
Bad habits to kick : using old-style JOINs - that old-style comma-separated list of tables style was replaced with the proper ANSI
JOIN
syntax in the ANSI-92 SQL Standard (more than 25 years ago) and its use is discouraged– marc_s
Jan 2 at 19:05
@marc_s - I am new to triggers and SQL (this is my first attempt at making one), so I'm trying to understand. For my case, only one row will ever be inserted into FOCALREFERENCEAREAS at a time (it's impossible to ever insert more than one at a time), so the Insert should only add the five rows specified to SharingPermissionsTest on trigger. It's certainly possible that the logic in my SQL statement does not reflect this idea though.
– MKF
Jan 2 at 19:11
1
Another bad habit - using 3 part names. You won't realize this until you (or someone else) attempts to create a second "environment" using a database that is not named "FocalAreas".
– SMor
Jan 2 at 19:16
Don't fall into the trap that "only one row will ever be inserted". This is a fallacy. At some point the system may change OR you may need to generate some data. Making triggers set based is not a luxury, it is the only way to write them correctly.
– Sean Lange
Jan 2 at 19:25