Re: Creating a Trigger on Access



I don't think a 'SELECT' trigger would be a good idea since data could be
access for reasons other than login. IMHO, a stored procedure would be the
best approach since you can include other login activities, like password
validation. For example:

CREATE PROCEDURE dbo.usp_LoginUser
@UserName varchar(30),
@Password varchar(30)
AS
SET NOCOUNT ON
DECLARE @ReturnCode int

UPDATE dbo.Users
SET LastLoginTime = GETDATE()
WHERE
UserName = @UserName AND
Password = @Password

IF @@ROWCOUNT > 0
BEGIN
--indicate login success
SET @ReturnCode = 0
END
ELSE
BEGIN
--indicate login failure
SET @ReturnCode = 1
END

RETURN @ReturnCode
GO


--
Hope this helps.

Dan Guzman
SQL Server MVP

<iamalex84@xxxxxxxxx> wrote in message
news:1148414912.126785.4600@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,

I am trying to create a trigger to update a datetime field when a user
logs in to their account. Is there a way to create a trigger that
updates a field when the table is accessed? The only other possible
way I can think of to accomplish this would be to write code that
updates a field on submit so that it trips the trigger I have to update
the time. This does not seem especially efficient, though.



.



Relevant Pages

  • Re: Creating a Trigger on Access
    ... username and password to it. ... access for reasons other than login. ... DECLARE @ReturnCode int ... I am trying to create a trigger to update a datetime field when a user ...
    (microsoft.public.sqlserver.security)
  • Re: Creating a Trigger on Access
    ... username and password to it. ... @LastLoginTime datetime OUTPUT ... DECLARE @ReturnCode int ... --indicate login success ...
    (microsoft.public.sqlserver.security)
  • Re: Logon triggers
    ... it's not that if you mess up the login trigger that no one can ... You can still connect on the DAC (Dedicated Administrator ... Connection) to drop the trigger. ... Event Notifications since in the future I want to log DDL & SQL Config ...
    (microsoft.public.sqlserver.security)
  • Re: are triggers atomic?
    ... If I write a trigger for a file, ... fact that it will conclude before another login on say port ... Maybe I should have been using a readu lock in my ...
    (comp.databases.pick)
  • Trigger**
    ... I've a following trigger which is fired in update status and make all ... destination table) ... ,but when I change the emp_status (by another login which has not access to ... table,an error occurred that you have no permission to update the second ...
    (microsoft.public.sqlserver.programming)