Results 1 to 7 of 7

Thread: Script

  1. #1
    Join Date
    Jul 2004
    Posts
    268

    Unanswered: Script

    Hi All,

    When I run the script below I get the error "Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name '#table'".


    CREATE TABLE #table (Check_Log VARCHAR(1000), Log_Time datetime default GetDate())

    INSERT #table(Check_Log)
    EXEC master..xp_cmdshell 'osql -S server -U user -P password -d db -Q"DBCC CHECKDB"'

    EXEC master..xp_cmdshell 'bcp dbname.user.#table out Z:\Test\CheckDBRes.txt -S server -U user -P password'

    SELECT * FROM #table

    IF EXISTS (SELECT * FROM #table
    WHERE Check_Log = 'CHECKDB found 0 allocation errors and 0 consistency errors in database')

    PRINT 'No errors'

    ELSE

    RETURN

    DROP TABLE #table

    Can you please tell what I am doing wrong?

    Thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Didn't we do this laready?

    All you had to do was curt and paste my origina;
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Jul 2004
    Posts
    268
    This is a little bit different. Your script doesn't put the results of checkdb into the text file. But this is one of the requirements.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You will need to make this a permanent table

    Also, make sure you put the batch column back in
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Jul 2004
    Posts
    268
    What is the purpose of the batch column?

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    So that multiple processes can use trhe samme table, you can retain all of the logs, and then only ftp out 1 "batch" dbcc process at a time.

    Trust me it will make life a lot easier

    http://www.dbforums.com/showthread.php?t=1612711
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Jul 2004
    Posts
    268
    Thanks for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •