sp_setnetname (version 6.5)

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.

Syntax

sp_setnetname @server [ = 'server'], @netname [ = 'netname']

where

@server
Is the name of the remote server as referenced in user-coded remote stored procedure call syntax. Exactly one row in sysservers must already exist to use this @server.
@netname
Is the network name of the computer to which remote stored procedure calls will be made. This name must match the Windows NT machine name, and it can include characters, such as hyphens, that are not allowed in SQL Server identifiers. In most cases, setting the @netname to the network machine name enables remote stored procedure calls to a SQL Server running on a remote machine with a name that is not legal in SQL Server.

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.

Remarks

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.

Example

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 
  

Permissions

Only the system administrator can execute this procedure.