There's no TSQL command to generate a CREATE script. The code to generate such DDL script lives
inside the SMO API.
However, if you want to know where in the meta-data you find who owns the endpoint, check out
sys.endpoints (the principal_id column) and sys.server_principals.

Signature
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
> Tibor,
>
[quoted text clipped - 13 lines]
>>> thanks,
>>> jc
Craig Thomas - 14 Feb 2008 06:46 GMT
John,
If you use the Microsoft SQL Server 2005 Management Studio (no, not that SQL
Server 2005 Management Studio Express, the other one, the one that costs MSDN
dollars), you will find the Service Broker Objects in the "Object Explorer":
[-] MyServer (SQL Server 9.0.3054 - sa)
...[+] Databases
...[+] Security
...[-] Server Objects
.......[+] Backup Devices
.......[-] Endpoints
...........[+] System Endpoints
...........[+] Database Mirroring
...........[-] Service Broker
...............[ ] SapEndpoint <<<=== right-mouse click to script
...........[+] SOAP
...........[+] TSQL
Here's what I get:
/****** Object: Endpoint [SapEndpoint] Script Date: 02/13/2008 22:29:50
******/
CREATE ENDPOINT [SapEndpoint]
AUTHORIZATION [sa]
STATE=STARTED
AS TCP (LISTENER_PORT = 4022, LISTENER_IP = ALL)
FOR SERVICE_BROKER (MESSAGE_FORWARDING = DISABLED
, MESSAGE_FORWARD_SIZE = 10
, AUTHENTICATION = CERTIFICATE [SapTransportCertificate]
, ENCRYPTION = REQUIRED ALGORITHM RC4)
This includes the authorization and certificate information.
If you're in the business of finding the information from the system views,
it is all there. SQL Server Management Studio makes it much easier to access.
HTH...
Thanks,
--Craig.