Script fails on SQL 2000

  • I tried this script on SQL 2000 and it fails at

    INSERT INTO @InputBuffer(EventType,Parameters,EventInfo)

    EXEC (@SQL)

    Cannot run execute in a insert statment.

    I am new to sql so any help Please

    Thanks

  • On SQL Server 2000 you cannot insert the results of an exec into a table variable. (you can do this on 2005 and 2008 though). You could try to use a temporary table as a target though.

    Example:

    CREATE TABLE #foo ( a INT )

    GO

    DECLARE @q VARCHAR(1000)

    SET @q = 'select 1 as A'

    INSERT INTO #foo

    EXEC ( @q )

    On SQL Server 2005 however, your query would work, e.g.:

    DECLARE @q VARCHAR(1000)

    SET @q = 'select 1 as A'

    DECLARE @table TABLE ( a INT )

    INSERT INTO @table

    EXEC ( @q )

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • I'm trying to get the script from "Tracking Illicit Users" to work on sql 2000. This code didn't return any results thogu I did not get the error.

    Is their something eles in the script that needs to be changed for sql 2000?

  • rdimaria (1/15/2008)


    I'm trying to get the script from "Tracking Illicit Users" to work on sql 2000. This code didn't return any results thogu I did not get the error.

    Is their something eles in the script that needs to be changed for sql 2000?

    It should work (the script seems to use the 2000 system tables only anyway). Try replacing the table declaration with:

    IF OBJECT_ID('tempdb..#InputBuffer') IS NOT NULL

    DROP table #InputBuffer

    CREATE TABLE #InputBuffer (

    EventType VARCHAR(30) ,

    Parameters INT ,

    EventInfo NVARCHAR(4000)

    )

    and the @InputBuffer wit #InputBuffer everywhere else

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Still no results

    Commented out this code and got results

    So I guess I don't have a issue with logins right now.

    Thanks for the help.

    AND (

    P.program_name LIKE 'Microsoft SQL%'

    OR P.program_name LIKE 'MS SQLEM%'

    OR P.program_name LIKE 'SQL Query Analyser%'

    )

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

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