Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

Read current sql server error log.

Total Hit ( 3300)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


This procedure reads the current SQL Error Log. Optionally it can read any log (or text file) specified by @LogFilename

Click here to copy the following block
-- Description:This procedure reads the
--   current SQL Error Log. Optionally it can
--   read any log (or text file) specified b
--   y @LogFilename

Create PROCEDURE [dbo].[sp_ReadErrorLog]
   @LogFilename [varchar](1000) = NULL
AS
SET NOCOUNT ON
DECLARE
   @CMDStatement [varchar](8000)
IF @LogFilename IS NULL
   BEGIN
       EXEC master.dbo.xp_regread
           'HKEY_LOCAL_MACHINE',
           'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\Parameters',
           'SQLArg1',
           @param = @LogFilename OUTPUT
       SET @LogFilename = RIGHT(@LogFilename, LEN(@LogFilename) - 2)
   END
--print @LogFilename
CREATE TABLE #LogFile
(
   [Line_id] [int] NOT NULL IDENTITY(1, 1),
   [LogText] [varchar](8000)
)
SET @CMDStatement = 'TYPE "' + @LogFilename + '"'
INSERT INTO #LogFile([LogText])
   EXEC master.dbo.xp_cmdshell @CMDStatement
SELECT * FROM #LogFile
DROP TABLE #LogFile
SET NOCOUNT OFF
GO


Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.