I get an error when I execute the command below from a DOS window开发者_JS百科 in Windows XP with SQL Server 2008. -S is the option to specify the server name.
error: Sqlcmd: '-S': unknown option.
sqlcmd –S localhost –d databasename -i C:\files\somefile.sql –E
It's working now using '.' as the server name when I typed the line manually. What I did earlier was type the command in an editor, copied the ine and pasted into the command line. My guess is that an invisible control character got in there during the copy. I opened another dos window and typed a similar command using 'localhost' and it worked. I never used sqlcmd to connect to a server so I thought my syntax was wrong.
localhost, . & (local) should all work and if you use a non existent server name it will complain that it couldn't connect. It shouldn't say -S is not an option.
Is localhost the correct reference to use? Try sqlcmd -L to get the list of servers.
LocalHost
is for IIS
(LOCAL)
is for SQL Server. Or you can use a period
精彩评论