Sets the network names in sysservers to their actual network machine names for remote computers running SQL Server. Names can include hyphens and other non-alphabetic characters. This procedure can be used to enable execution of remote stored procedure calls to machines that have network names containing invalid SQL Server identifiers.
sp_setnetname @server [ = 'server'], @netname [ = 'netname']
where
If a DB-Library alias matching the @netname is defined on the SQL Server machine, the connection string information in that alias is used to connect to the remote SQL Server.
Because Transact-SQL syntax does not usually recognize characters such as a hyphen in an object name, some remote stored procedure calls to Windows NT computers that have a machine name containing a hyphen can cause problems. Use this procedure to differentiate the values in sysservers.srvname versus sysservers.srvnetname.
For example, if your Windows NT Server machine name is MY-NT-PC, SQL Server Setup warns you that this computer name contains an invalid identifier, the hyphen (-). If your network system administrator requires MY-NT-PC to remain the machine name, then the system administrator can use sp_addserver and sp_setnetname to keep the server's network name MY-NT-PC while the computer's local name is another name that contains valid SQL Server identifiers.
For example:
sp_addserver 'MY_NT_PC', 'local' sp_setnetname 'MY_NT_PC', 'MY-NT-PC'
This procedure aids replication in situations where Windows NT machines with invalid SQL Server names are involved.
This example is a typical administrative sequence on the SQL Server that issues the remote stored procedure call.
EXECUTE sp_addserver 'Win_NT1' EXECUTE sp_setnetname 'Win_NT1','Win-NT1' EXECUTE Win_NT1.master.dbo.sp_who
Only the system administrator can execute this procedure.