Click here to Skip to main content
12,298,463 members (47,383 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: SQL-Server
Hi, I am Satish...........

How to get current logged in user info of dnn using Stored Procedures in Sql Server?

Thanks in Advance............
Posted 4-Dec-12 18:51pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

use this one.
SELECT  SUSER_NAME()
  Permalink  
Comments
sat4code 16-Apr-13 7:51am
   
thank u for response
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Hi ,

Check the following Database Trigger Script

CREATE TRIGGER [DDLTrigger_Sample]
    ON DATABASE
    FOR CREATE_PROCEDURE, ALTER_PROCEDURE, DROP_PROCEDURE
AS
BEGIN
    SET NOCOUNT ON;
    DECLARE @EventData XML = EVENTDATA();
 
    DECLARE @ip VARCHAR(32) =  (
            SELECT client_net_address
                FROM sys.dm_exec_connections
                WHERE session_id = @@SPID
        );
 
    INSERT AuditDB.dbo.DDLEvents
    (
        EventType,
        EventDDL,
        EventXML,
        DatabaseName,
        SchemaName,
        ObjectName,
        HostName,
        IPAddress,
        ProgramName,
        LoginName
    )
    SELECT
        @EventData.value('(/EVENT_INSTANCE/EventType)[1]',   'NVARCHAR(100)'), 
        @EventData.value('(/EVENT_INSTANCE/TSQLCommand)[1]', 'NVARCHAR(MAX)'),
        @EventData,
        DB_NAME(),
        @EventData.value('(/EVENT_INSTANCE/SchemaName)[1]',  'NVARCHAR(255)'), 
        @EventData.value('(/EVENT_INSTANCE/ObjectName)[1]',  'NVARCHAR(255)'),
        HOST_NAME(),
        @ip,
        PROGRAM_NAME(),
        SUSER_SNAME();
END

Regards,
GVPrabu
  Permalink  
v2
Comments
sat4code 16-Apr-13 7:53am
   
thanx u for your response
sat4code 22-May-13 23:55pm
   
Thank you for you reply
gvprabu 23-May-13 3:44am
   
my solution is helped u right, then u could have accept my answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160525.2 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100