export data from sql server 2005 table to text file

  • Hii

    I want to transfer data from table to a text file.I m trying to use bcp utility and xp_cmdshell.but the export is not successful.

    My query is:

    EXEC master..xp_cmdshell'bcp "Select * from AH_PRE_REQUEST" queryout "c:\dept.txt" -c -T -x'

    but erros is..................................

    SQLState = S0002, NativeError = 208

    Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'AH_PRE_REQUEST'.

    SQLState = 37000, NativeError = 8180

    Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.

    NULL

  • polo.csit (8/5/2009)


    Hii

    I want to transfer data from table to a text file.I m trying to use bcp utility and xp_cmdshell.but the export is not successful.

    My query is:

    EXEC master..xp_cmdshell'bcp "Select * from AH_PRE_REQUEST" queryout "c:\dept.txt" -c -T -x'

    but erros is..................................

    SQLState = S0002, NativeError = 208

    Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid object name 'AH_PRE_REQUEST'.

    SQLState = 37000, NativeError = 8180

    Error = [Microsoft][ODBC SQL Server Driver][SQL Server]Statement(s) could not be prepared.

    NULL

    have you tried including the schema name in your sql expresssion?

    EXEC master..xp_cmdshell'bcp "Select * from dbo.AH_PRE_REQUEST" queryout "c:\dept.txt" -c -T -x'

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

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