I have this situation. I created a logon script to block any session for specific logins. These logins are in a table. So the behaviour of my script is simple. Get the login from the table, compare it with the login who wants to access and then insert some information to another table. The question here is:
I tested in one instance and everything went fine but in other instance and now in the previous instance when I enable the logon trigger appears a pop up and block my personal account. My account is not included in the table so should not have this behaviour. Obviously the part to insert date in a table, doesn't work. Also other logins have been blocked
CREATE TRIGGER Accounts_V1 ON ALL SERVER WITH EXECUTE AS 'DBA' FOR LOGON AS BEGIN DECLARE @Logon as varchar(50) DECLARE @AppName as varchar(250) DECLARE @ComputerName as varchar(50) DECLARE @ServerName as varchar(50) DECLARE @Original_Login as varchar(50) SET @ComputerName = HOST_NAME () SET @ServerName = @@servername SET @AppName = APP_NAME() SET @Original_Login = ORIGINAL_LOGIN () SET @Logon = ( select LoginName FROM [dba]..[MissusesAccounts_test] where LoginName NOT like '%WIN%' and ( @AppName like '%Microsoft%' or @AppName like '%PowerShell%' ) and @ComputerName not like '%sql%') if (@Logon = @Original_Login) INSERT INTO [dba]..[LogonAccounts_test] ([ComputerName] ,[ServerName] ,[AppName] ,[Logon]) VALUES (@ComputerName ,@ServerName ,@AppName ,@Logon) BEGIN print 'This login: '+@Logon+' should not be used by individuals to run interactive queries in ' +@AppName+' , and email has been sent to the Development Manager to investigate' END END REVERT
SET @Logon =...?