| | This stored procedure accepts a message, filename, overwrite mode as an input parameters and logs that message to the specified file on the server | 
 |  Click here to copy the following block |  | CREATE PROC Log_to_file @msg VARCHAR(100),
 @file VARCHAR(100),
 @overwrite BIT = 0
 AS
 
 
 
 BEGIN
 SET NOCOUNT ON
 DECLARE @execstr VARCHAR(255)
 SET @execstr = RTRIM('echo ' + COALESCE(LTRIM(@msg),'-') + CASE WHEN (@overwrite = 1) THEN ' > ' ELSE ' >> ' END + RTRIM(@file))
 EXEC master..xp_cmdshell @execstr
 SET NOCOUNT OFF
 END
 | 
 |