Have a Sql Script file name spCreation.sql with the following contents.
CREATE PROCEDURE dbo.usp_select_customers
as
Begin
SELECT EMP.NAME, EMP.ID FROM analysis.customerDB.dbo.employeetbl
END
Open this file and execute on Queryanalyser, without creating a Linked Server “Analysis” it is not throughing any error and query executed successfully.
Execute the same sql file through sqlcmd like follows on command prompt.
sqlcmd -s [Server] [Database] [Login] [Password] spCreation.sql
it is throwing an exception for the notify server.
Can any one explain how sqlCmd execution behaviour and query analyser execution behaviour?
Error message follows
Msg 7202, Level 11, State 2, Server VIJAY-PC, Procedure usp_select_customers, Line 4 Could not find server ‘analysis’ in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserv er to add the server to sys.servers.
Running the query in SSMS gives the very same error:
So the problem is not the difference between sqlcmd or SSMS, it must be something else. For instance you’re running against a different machine, or you simply don’t run it in SSMS but simply check the syntax.