xp_cmdshell returns login failed for sa

  • I need to run the following command on a SQL2008 R2 server:-

    master..xp_cmdshell 'osql -Usa -Pabc -Q"EXEC master..sp_help_revlogin" -dmaster -o\\c:\sql_logins.sql'

    This command is running fine on another server producing the correct output - a list of sql logins to a file on the file system

    However, on this particular server it is returning

    Login failed for user 'sa'.

    This is despite me changing the sa password to a simple password of abc

    Any assistance appreciated

    Thanks

  • Are you sure you are running the command against the correct instance of SQL Server?

    You haven't specified the -S parameter, so you will be connecting to the default instance on that server.

  • Thank You.

    Thats fixed it:-)

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

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