Xp_logevent

Hi there,
I need to send the content of a specific table (two columns) to the event log. can it be done ? can I do it through an array?
thanks.

xp_logevent accepts a message number and a string for the message. If this is a small table you could do:
SELECT @xml = (SELECT * FROM tbl FOR XML RAW)
EXEC xp_logevent 50000, @xml
Beware the the string you pass to xp_eventlog cannot be longer than 2048 characters. The XML tags takes up some place, so if the data fits, you could think of formatting the data in a more compact way, but then you would need to write the code yourself.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • Xp_logevent permission

    Hi,
    I am getting below error
    The SELECT permission was denied on the object 'ServiceAgent', database 'HOFHUB', schema 'dbo'. 
    The EXECUTE permission was denied on the object 'xp_logevent', database 'mssqlsystemresource', schema 'sys'.
    Can anyone please help how to solve it?
    Thanks

    Hi Arup.mca,
    How did you get these two errors? Were you trying to execute a query to retrieve data from a table/view? Or were you trying to execute Microsoft SQL Server Agent jobs when you got these two errors?
    If you were trying to execute a query when you got the errors, you need to grant the necessary permissions to the user. In this case, you need to grant SELECT and EXECUTE permission to the user.
    If you were trying to execute Microsoft SQL Server Agent jobs when you got these two errors, then you don’t need to grant other specific permission to the user. To configure a user to create or execute Microsoft SQL Server Agent jobs, you must first add
    an existing SQL Server login or msdb role to one of the following SQL Server Agent fixed database roles in the msdb database: SQLAgentUserRole, SQLAgentReaderRole, or SQLAgentOperatorRole. For more details about Configure a User to Create and Manage SQL Server
    Agent Jobs, please refer to the following article:
    http://msdn.microsoft.com/en-us/library/ms187901.aspx
    If the user is added to the right SQL Server Agent Fixed Database Role, we don’t need to grant other specific permission to the user, it can be very useful to manage SQL Server Agent jobs. For more details about SQL Server Agent Fixed Database Roles, please
    refer to the following article:
    http://msdn.microsoft.com/en-us/library/ms188283.aspx
    If you have any question, please feel free to let me know.
    Regards,
    Jerry Li

  • Success is possible

    I have had success with a Windows XP hooked up to a Linksys WRT54G connecting to an AirPort Express and iBook. The AirPort Express is wired to another XP and an HP PSC 1350 all-in-one. The iBook has access to internet from either the WRT54G or the AX and gets use of the printer from the AX. I don't expect responses to this but I just wanted to let it be known that this kind of set up is extremely possible.

    If I understood you correctly  you need something like that
     BEGIN TRANSACTION
      UPDATE Table1 …
      SET @Err = @@ERROR
      IF @Err <> 0
    BEGIN
    ROLLBACK TRANSACTION
    [RAISERROR/XP_LOGEVENT]
    RETURN (@Err)
    END
      delete Table1 …
      SET  @Err = @@ERROR
      COMMIT TRANSACTION
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • Multi-User Issues

    I've taken over development of a Vs2003(vB)/MsSql2000 application which usually runs in on a Windows 2000 server with multiple workstations running the application simultaneously in Remote Desktop Sessions.
    The central user interface element of the application is an un-databound grid (actually a farpoint spreadsheet) which displays sql table rows that are accessable from every workstation. The grid refreshes its content whenever a specific subroutine is called.  That subroutine performs a query which loads its results into a collection which is then loaded into the grid. The subroutine is called during startup and at other times using the rather elaborate mechanism described below.  Each workstation also has the ability to modify any row in the grid via a dialog-based editor.  The grid itself is not setup to allow inplace editing.
    The grid usually contains about 200 records and 20-50% of these records get modified (some repeatedly) every hour.
    My question involves the classic multi-user issues of keeping all of the seperate workstation's grids current as individual workstations make modifications to the data.
    What is Microsoft's recommended method for handling multi-user data-refresh requirements in custom applications written in VB.NET2003 with MsSQL2000?
    Now that you know what I'm looking for, let me add a little more detail.  The existing code handles this multi-user refresh issue in the following way...
    A SQL Trigger is attached to the SQL Table's Insert/Modify and Delete events. That Trigger calls the xp_logevent built-in stored procedure to make an entry in the NT Event Log.
    The application contains a subroutine to handle EventLog("Application").EntryWritten messages.  That subroutine calls the subroutine (mentioned earlier) which refreshes the grid contents through a new SQL query.
    In this way, whenever any workstation changes the table data, a trigger fires which makes a log entry and broadcasts an EntryWritten message into the global windows environment.  The individual applications (each running in their own RDP session) hear the message and respond by refreshing their grid.
    This all seems a little "rube goldberg" to me, but it has worked for many years.
    That is, until we moved the SQL2000 server to a seperate machine to improve program responsiveness.
    Now when the trigger is fired and the log entry is made, the EntryWritten message is broadcast into the windows environment of the dedicated SQL server where there are no applications listening for it.  Meanwhile, the applications continue to run with unrefreshed data on the (now) dedicated RDP server from where the EntryWritten messages cannot be "heard".
    So my question really comes down to this...
    In an environment where the SQL server and the RDP server are two seperate machines, what is the best method for coordinating multi-user screen refreshes across seperate applications running in distinct RDP Client sessions?
    Thanks in advance for any assistance.
    Peace,
             Colt Taylor
             Computer Golf Sofware

    Colt,
    Is this still an issue?
    Thanks!
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

Maybe you are looking for

  • Item text is not coming in production server

    hello abap gurus, i developed a smart forms where i am using item text field insted of master data records. using that while i run programe on developement server. the values coming are right but when i  run that programe after moving it on productio

  • Raw images in Photoshop Elements 12

    I connected the camera to my Mac Book Air to download my latest photos using a Nikon D3300. Went to open a raw photo in my adobe photoshop elements 12 and it claims it is unable to read/open the file. I just downloaded and opened other photos a week

  • How to add Check box to a static Drop down list (bases on a selection list) and allow mulity select in it?

    Dear All, I created a text field in my project (Light switch 201, C#), this text field has a static list which I filled manually. when I click in this text box I get a dropp down list which allow me to chose only one value from it. Now what I want to

  • Can't download songs because itunes wants older versions of it 7.4 and 7.2

    Okay here's my issue. I want to buy a new song from iTunes and most songs come up with this error. It says I need to download 7.2 or 7.4 versions of i Tunes, but I already have 7.5!! Plus everytime I open up iTunes it says I need to update to 7.5 eve

  • Diable special keys in projector

    is there a way to make the projector ignor '.' (full stop) - so not to jump into my next scene, when I don't want it to? I have a keyboard listener, but according to a trace, the action of the '.' happens before the listener even knows the key is pre