none
Incorrect Syntax near the keyword 'with'

    Pregunta

  • Hi,

    I am trying to use the stored procedure described in this post: http://www.sqlservercentral.com/scripts/RSExecutionLog/66858/ to save SSRS execution logs.  When I run the code from that website, I get the following errors: "Inccorect syntax near ' '." and "Incorrect syntax near the keyword 'with'."  I can't figure out why I am getting these errors.  I am using SQL Server 2008 - could that be the issue here?

     Here is the section of code that causes the problem:

    CREATE

     

    PROCEDURE dbo.Upd_RSExecutionLog

    AS

    --***********************************

    -- Initialise

    --***********************************

    DECLARE

     

    @myRows INT

    DECLARE

     

    @myTimeEnd DATETIME

    DECLARE

     

    @myTime DATETIME

    SET

     

    @myTimeEnd = (SELECT MAX(TimeEnd) FROM RSExecutionLog.dbo.ExecutionLogs)

    SET

     

    @myTime = GETDATE()

    --***********************************

    -- Lookup Tables

    --***********************************

    -- FormatTypes

    INSERT

     

    INTO RSExecutionLog.dbo.FormatTypes

     

     

    (Format)

    SELECT

     

    DISTINCT

    Format

    FROM

     

    ReportServer.dbo.ExecutionLog WITH(NOLOCK)

    WHERE

     

    Format IS NOT NULL

    AND

     

    Format COLLATE Latin1_General_CI_AS NOT IN (SELECT Format

     

    FROM RSExecutionLog.dbo.FormatTypes)

    SET

     

    @myRows = @@ROWCOUNT

    INSERT

     

    INTO RSExecutionLog.dbo.RunLogs

     

     

    ([Event]

     

    ,[When])

    VALUES

     

     

     

    ('Inserted ' + CONVERT(nvarchar(50), @myRows) + ' rows into table FormatTypes'

     

    ,@myTime)

    -- Machines

    INSERT

     

    INTO RSExecutionLog.dbo.Machines

     

     

    (InstanceName)

    SELECT

     

    DISTINCT

    InstanceName

    FROM

     

    ReportServer.dbo.ExecutionLog WITH(NOLOCK)

    WHERE

     

    InstanceName IS NOT NULL

    AND

     

    InstanceName COLLATE Latin1_General_CI_AS NOT IN (SELECT InstanceName

     

    FROM RSExecutionLog.dbo.Machines)

    viernes, 30 de julio de 2010 16:39

Respuestas

  • OK, I'm not sure how this fixed the problem, but I retyped this section manually (rather than copying and pasting) and it now works.  I typed the same exact thing, character for character...
    • Marcado como respuesta Smithochris viernes, 30 de julio de 2010 16:57
    viernes, 30 de julio de 2010 16:57