Click here to Skip to main content
Rate this: bad
good
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 at 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 at 16-Apr-13 7:53am
   
thanx u for your response
sat4code at 22-May-13 23:55pm
   
Thank you for you reply
gvprabu at 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
0 OriginalGriff 404
1 Sergey Alexandrovich Kryukov 387
2 Shemeemsha RA 148
3 Abdul Samad KP 125
4 CPallini 100
0 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web04 | 2.8.140916.1 | Last Updated 22 Feb 2013
Copyright © CodeProject, 1999-2014
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