rookie need help to understand sp

  • I have inherited a sql 2005 cluster and am far from a dba. I am trying to understand the below sp.. can anyone give me a brief overview of what this is doing??? THanks for any help

    set ANSI_NULLS ON

    set QUOTED_IDENTIFIER ON

    GO

    ALTER PROCEDURE [dbo].[psp_user_get_login_activity]

    (

    @p_language_code NCHAR(2),

    @p_begin_datetime DATETIME,

    @p_end_datetime DATETIME

    )

    AS

    BEGIN

    SET NOCOUNT ON;

    DECLARE @save_error INTEGER;

    DECLARE @save_rowcount INTEGER;

    SELECT

    (au.FIRST_NAME + ' ' + coalesce(au.MIDDLE_NAME+' ','') +au.LAST_NAME) AS FULL_NAME,

    au.LAST_NAME,

    au.EMAIL,

    ula.EVENT_TIMESTAMP,

    CASE ula.ACTION

    WHEN 0 THEN N'F'

    WHEN 1 THEN N'S' END AS LOGIN_STATUS,

    ula.IP_ADDRESS

    FROM

    user_login_activity ula INNER JOIN

    all_users au ON ula.user_id = au.user_id

    WHERE ula.EVENT_TIMESTAMP >= @p_begin_datetime

    AND ula.EVENT_TIMESTAMP < DATEADD(d,1,@p_end_datetime);
    SELECT
    @save_error = @@ERROR, @save_rowcount = @@ROWCOUNT;
    IF @save_error <> 0 GOTO error_exception;

    RETURN 0;

    error_exception:

    RETURN @save_error;

    END;

  • Hi,

    This stored procedure appears only to select the Fullname, email address, time , login status and IP address of all events that happened between the begin datetime and end datetime.

    He is just joining to the all_users table to get the user details of the users who made the events during that time.

    Other than that he just checks if there were any errors.

    Hope that helps.

  • thanks alot!!!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply