The server name is simply the name of the SQL Server or named instance i.e. the hostname (for a default instance), or <host>/<instname>
Starting with release 6.40 however there are some special considerations that should be taken into account. When running with kernel release 6.40 or later, the R/3 system will prepend a protocol specifier to the server name. Example:
1. For a server running on the same server:
np:<servername>
2. For a remote server:
tcp:<servername>
This forces the connection to be made with a named pipes and tcp/ip protocols respectively.
When specifying the server name you can override this by setting your own protocol (tcp: or np:), or you can make R/3 avoid setting any prefix by using simply :<servername> - a colon in front of the server name.
例程一
report zdbcon .
data: dbn(128).
EXEC SQL.
CONNECT TO 'DAN1'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'DAN1'
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
write: / 'current database name', dbn.
DAN1在DBCON表中配置
CON NAME DAN1
DBMS MSS
USER NAME iis_log
PASSWORD CON ENV
MSSQL_SERVER=tcp:###.###.###.### MSSQL_DBNAME=iislog
例程二
Here is an example for how to connect to another server with CON_NAME=BSK. The example assumes BSK is running R/3:
EXEC SQL.
CONNECT TO 'BSK'
ENDEXEC.
EXEC SQL.
SET CONNECTION 'BSK'
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / 'current database name', DBN.
EXEC SQL.
SET CONNECTION DEFAULT
ENDEXEC.
EXEC SQL.
SELECT db_name() INTO :DBN FROM SVERS
ENDEXEC.
WRITE: / 'current database name', DBN.
notes: https://websmp130.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/sapnotes/index2.htm?numm=178949&nlang=EN&smpsrv=https%3a%2f%2fwebsmp103%2esap-ag%2ede