Question

I am executing a script by using file like below:

EXEC master.dbo.xp_cmdshell 'sqlcmd -d TE07 -S ServerName -i D:\TE07.sql'

When executing the above line I am getting the below error:

Msg 18456, Level 14, State 1, Server WIN-T7NMRSDEBNP, Line 1
Login failed for user 'NT AUTHORITY\ANONYMOUS LOGON'.

I have read a lot but I am not clear about this. In many articles it is define as a LinkedServer issue. Can anyone please suggest me.

Was it helpful?

Solution

We have to use username and password also while executing the sql file using cmdshell:

EXEC master.dbo.xp_cmdshell ‘sqlcmd -D db_name -S server_name -U username -P password -i sqlfile’

Use the above format

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top