MySQL to MSSQL

  • I have a set of query which is being used for generating Audit reports which is not being supported in MSSQL.

    SELECT distinct DATE_FORMAT(arc_endTime,"%Y-%m-%e-%H:%i:%s") "Event Time",

    arc_destinationHostName "Host Name",

    arc_destinationUserName "User Name",

    arc_sourceHostName "From Host",

    arc_sourceAddress "From IP Address",

    arc_deviceCustomString2 "Database",

    arc_deviceCustomString1 "Object Name",

    arc_name "Procedure",

    arc_message "Action",

    arc_deviceEventClassId "Event ID",

    DATE_FORMAT(arc_eventTime,"%Y-%m-%e-%H:%i:%s") "Logger Time",

    arc_deviceProduct "Device Product"

    FROM events

    WHERE arc_deviceProduct = 'SQL Server'

    AND arc_deviceCustomString2 = 'HR_Time'

    AND arc_deviceHostName = ‘enter device name here’

    If someone could help me to get this executed in SQL 2005 would be more helpful.

  • This should be pretty close

    😎

    SELECT distinct CONVERT(DATETIME,arc_endTime,120) AS [Event Time],

    arc_destinationHostName AS [Host Name],

    arc_destinationUserName AS [User Name],

    arc_sourceHostName AS [From Host],

    arc_sourceAddress AS [From IP Address],

    arc_deviceCustomString2 AS [Database],

    arc_deviceCustomString1 AS [Object Name],

    arc_name AS [Procedure],

    arc_message AS [Action],

    arc_deviceEventClassId AS [Event ID],

    CONVERT(DATETIME,arc_eventTime,120) AS [Logger Time],

    arc_deviceProduct AS [Device Product]

    FROM events

    WHERE arc_deviceProduct = 'SQL Server'

    AND arc_deviceCustomString2 = 'HR_Time'

    AND arc_deviceHostName = 'enter device name here'

  • Thanks for your quick reply...I am getting the error message as:

    Invalid object name 'events'.

  • That means that your database doesn't have a table (or view) called events. Check that you're running the query in the correct db and that the table exists.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • If the table exist, it could be in another schema. Change the code to (schema_name).[events] if you find it.

    😎

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply