Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Log information in to a Table! Expand / Collapse
Author
Message
Posted Sunday, September 16, 2012 11:50 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, March 26, 2014 5:30 AM
Points: 26, Visits: 195
Hi,

I have created a SP which is used for Backup/Restore. Now the problem is I need to create a table which is used for collecting the log information,

I.E When Procedure is executed, the execution of Procedure should be in the table which should contain following fields

Who(Which user used the Procedure), What they executed(backup/Restore) & Path (Where backup is taken or Restored etc).


Any thoughts on this ???

Post #1359905
Posted Sunday, September 16, 2012 8:08 PM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 7:22 PM
Points: 1,167, Visits: 1,207
$ammy (9/16/2012)
Hi,

I have created a SP which is used for Backup/Restore. Now the problem is I need to create a table which is used for collecting the log information,

I.E When Procedure is executed, the execution of Procedure should be in the table which should contain following fields

Who(Which user used the Procedure), What they executed(backup/Restore) & Path (Where backup is taken or Restored etc).

Any thoughts on this ???


I'm probably not fully understanding what you're asking, but it sounds like you just want an insert into your logging table (create a table for this log info if you don't have it already). You probably already have a parameter on your proc whether it's for Backup or Restore. Is the path a parameter of the procedure as well? (probably). You can get the user from suser_sname().

INSERT dbo.YourLoggingTable (UserId, ExecutionType, Filename, ExecutionStart) VALUES (suser_sname(), @ExecType, @Filename, GETDATE());

Post #1359946
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse