trying to run a bcp command from sql server 2005 and get error Login failed for user 'NT AUTHORITY\SYSTEM' Can you help? thanks

  • SQLState = 28000, NativeError = 18456

    Error = [Microsoft][SQL Native Client][SQL Server]Login failed for user 'NT AUTHORITY\SYSTEM'.

    SQLState = 42000, NativeError = 4060

    Error = [Microsoft][SQL Native Client][SQL Server]Cannot open database "select * from cycledate" requested by the login. The login failed.

    NULL

    This is the query.

    SET QUOTED_IDENTIFIER OFF

    declare @output varchar(5000)

    SELECT @output ='bcp "select * from cycledate" out "c:\text.txt" -c -q -S -T'

    EXEC master..xp_cmdshell @output

    I tried to give elevated rights to NT\AUTHORTY\SYSTEM but still get the same error. Has anyone run into this and if so what was your solution

    thanks

  • Assuming you are running this query on the SQL Server itself, try this (substitute dbname.schema with whatever database & schema the table is in):

    [font="Courier New"]SELECT @output ='bcp "select * from dbname.schema.cycledate" queryout "c:\text.txt" -c -q -S -T'

    [/font]



    Scott Duncan

    MARCUS. Why dost thou laugh? It fits not with this hour.
    TITUS. Why, I have not another tear to shed;
    --Titus Andronicus, William Shakespeare


  • Scott,

    Thanks very much it works like a charm as:

    SELECT @output ='bcp "Select * from cycleprocess.dbo.cycledate" queryout "c:\text.txt" -c -q -S -T'

    Rick

    ex Wentworthville guy 🙂

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

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