• arooj300 (3/3/2014)


    Hi All,

    I have created stored procedure for checking the cpu usage and connection string.

    ----check the number of users---

    EXEC sp_who2 'Active'

    -----check the number of connection----

    SELECT

    DB_NAME(dbid) as DBName,

    COUNT(dbid) as NumberOfConnections,

    loginame as LoginName

    FROM

    sys.sysprocesses

    WHERE

    dbid > 0

    for above script I have created one job which will run every 1 hr and that information will be stored into the txt files through

    job-properties-step-advanced-outfiles.

    But the problem is the all the information is stored in one file.

    actually what I want, for today when job will be started it will create one txt file and all the data will be stored in the same file and tomorrow again the job will start the samething happen.

    So everyday I want to create new txt files and when the job will start the data will be stored in that file.

    Is there any script or anyother solution, please share with me.

    Thanks...

    GROUP BY

    dbid, loginame

    I just wouldn't do this. You're creating a nightmare for yourself when someone asks to see the data. Just store the data in a table reserved for DBAs and call it a day.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)