?
Solved

How to write a SQL query to the errorlog

Posted on 2014-04-03
4
Medium Priority
?
287 Views
Last Modified: 2014-04-18
How would you write a SQL query result or a job output to the SQL errorlog? There's a program that needs to read a backup failure/success from the errorlog.
0
Comment
Question by:barnesco
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39975921
The built in procedure sp_readerrorlog will retrieve data from the error log.

Run EXEC sp_readerrorlog

Kelvin
0
 

Author Comment

by:barnesco
ID: 39975950
I want to write to the log, not retrieve it.
0
 
LVL 22

Expert Comment

by:Kelvin Sparks
ID: 39976162
Sorry misunderstood you as you said

There's a program that needs to read a backup failure/success from the errorlog.

The success/failure of backups is already in the SQL Server logs and can be extracted with the inbuilt sp above
0
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 2000 total points
ID: 39976367
You can use RAISERROR(...) WITH LOG

Restrictions:
The message is limited to 440 bytes AND
User issuing the RAISERROR must have ALTER TRACE permissions (or be a sysadmin)


You should also review these trace flags and see if they give you want you need:
3605
4032
If you use them, I would strongly urge you NOT to make them global settings, but only for your session; that is, do NOT include -1 in the values when setting these trace flags.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question