Results 1 to 9 of 9

Thread: i've tried Exec Master..xp_cmdshell 'bcp "DBCC CHECKDB" queryout "c:\Test.txt"'

  1. #1
    Join Date
    Sep 2004
    Posts
    6

    i've tried Exec Master..xp_cmdshell 'bcp "DBCC CHECKDB" queryout "c:\Test.txt"'

    Hi,
    i Exected...

    Exec Master..xp_cmdshell 'bcp "DBCC CHECKDB" queryout "c:\Test.txt"'

    i've tried through this SQL script in Query Analyser but.
    the Result is not storing in the Text file, and getting output this

    ---------------------------------------
    Password:
    NULL
    Do you want to save this format information in a file? [Y/n]
    Starting copy...
    SQLState = S1000, NativeError = 0
    Error = [Microsoft][ODBC SQL Server Driver]BCP host-files must contain at least one column
    NULL
    BCP copy out failed
    NULL
    ----------------------------------------
    Please help me, Successful Query.
    Thanks <b>Nosepicker</b>
    u r solutions is right...
    Which u gave the Query...
    Exec Master..xp_cmdshell 'osql -Uuserid -Ppassword -Sservername -ddatabase -Q"DBCC CHECKDB" > "c:\Test.txt"'

    i've Executed, It's work's fine in the VB6,VB.Net,ASP.Net...
    I've done project, i've facility to take Backup and Restore the Database...
    Last edited by sqldeveloper; 03-16-2005 at 01:01 AM.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Tried specify sql server name and login info in bcp?

  3. #3
    Join Date
    Dec 2004
    Posts
    502
    See if this works instead:

    Exec Master..xp_cmdshell 'osql -Uuserid -Ppassword -Sservername -ddatabase -Q"DBCC CHECKDB" > "c:\Test.txt"'

  4. #4
    Join Date
    Feb 2003
    Posts
    1,048
    Please post in the same thread when you need to reply to an existing post.

  5. #5
    Join Date
    Mar 2005
    Location
    Ottawa, Canada
    Posts
    1

    Post Results of Database Integrety Check

    When the results of your query is provided in the result window, simply click in the resulting pane and select FILE > Save As, and provide a name. The results will be saved.

  6. #6
    Join Date
    Mar 2005
    Posts
    1
    Create a job with the followig step:

    SET QUOTED_IDENTIFIER ON
    DBCC CHECKDB


    Select the advanced tab and fill in the output file section. When you run the job, the output will go to your file.

  7. #7
    Join Date
    Apr 2005
    Posts
    11
    How do I add a Windows id as the userid on osql?

    'osql -Uuserid -Ppassword -Sservername -ddatabase -Q"DBCC CHECKDB" > "c:\Test.txt"'

  8. #8
    Join Date
    Sep 2002
    Location
    Fantasy
    Posts
    4,254
    osql.exe -E -SServername -ddatabase -Q"DBCC CHECKDB" > c:\test.log

  9. #9
    Join Date
    Feb 2003
    Posts
    1,048
    As demonstrated by Mak, the -E switch means to use a trusted connection a.k.a. the user's windows account.

Posting Permissions

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