17.06.2013 Views

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

Beginning Microsoft SQL Server 2008 ... - S3 Tech Training

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Appendix A: System Functions<br />

@@REMSERVER<br />

Returns the value of the server (as it appears in the login record) that called the stored procedure.<br />

Used only in stored procedures. This one is handy when you want the sproc to behave differently<br />

depending on what remote server (often a geographic location) the sproc was called from.<br />

@@SERVERNAME<br />

Returns the name of the local server that the script is running from.<br />

If you have multiple instances of <strong>SQL</strong> <strong>Server</strong> installed (a good example would be a web hosting service<br />

that uses a separate <strong>SQL</strong> <strong>Server</strong> installation for each client), then @@SERVERNAME returns the following<br />

local server name information if the local server name has not been changed since setup:<br />

@@SERVICENAME<br />

Returns the name of the registry key under which <strong>SQL</strong> <strong>Server</strong> is running. This will be MS<strong>SQL</strong>Service if it<br />

is the default instance of <strong>SQL</strong> <strong>Server</strong>, or the instance name if applicable.<br />

@@SPID<br />

Returns the server process ID (SPID) of the current user process.<br />

This equates to the same process ID that you see if you run sp_who. What’s nice is that you can tell the<br />

SPID for your current connection, which can be used by the DBA to monitor, and if necessary terminate,<br />

that task.<br />

@@TEXTSIZE<br />

598<br />

Instance <strong>Server</strong> Information<br />

Default instance <br />

Named instance <br />

Virtual server — default instance <br />

Virtual server — named instance <br />

Returns the current value of the TEXTSIZE option of the SET statement, which specifies the maximum<br />

length, in bytes, returned by a SELECT statement when dealing with text or image data.<br />

The default is 4096 bytes (4KB). You can change this value by using the SET TEXTSIZE statement.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!