Free web development scripts for the webmasterDevelopment Scripts


 social media marketing services
 Site Navigation
Clicky Web Analytics
 o Development Scripts
 o Text Only Edition
 o PHP.net News
 o Tutorials
 o Register an account
 o New entries this week
 o Affiliates/Links
 o Contact Us
 o About us
 o Advanced Search

 Browse Path
 o 1 user online
 o Most users online: 67
 o Home
  o SQL
   o Miscellaneous
    o Script

 Member Login
User Name
Password

 Standards
Valid XHTML 1.0!
Valid 
CSS!

 Recommended Links
 o PHP Freaks
 o Paper Free Invoicing
 o Tutorials
 o Expired Domain Crawler

Script to Get Dynamic Port on Which the SQL Server Instance Listens (Rated 0)

Description:

As every SQL Server DBA might be aware, the default port for SQL Server on which it listens is 1433. But this holds only for the default instance. In a multi-instance environment, the port allocation is dynamic and is potentially different every time SQL Server is restarted. This script can be used to find the dynamic port of an instance, by scanning the registry.

This script gets the current instance name on the fly and needs NO customization. The script supports both SQL Server 7.x and SQL Server 2000.

Code starts here


CREATE TABLE #GetPort
(
token varchar(100),
value varchar(20))
go

DECLARE @inst varchar(200)
DECLARE @inst1 varchar(100)
IF(charindex('\',@@servername) > 0)
BEGIN
SELECT @inst = substring(@@servername,charindex('\',@@servername),50)
SELECT @inst = 'SOFTWARE\Microsoft\Microsoft SQL
Server'+@inst+'\MSSQLServer\SuperSocketNetLib\Tcp'
SELECT @inst1 = 'TcpDynamicPorts'
END
ELSE
BEGIN
SELECT @inst =
'SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib\Tcp'
SELECT @inst1 = 'DefaultPort'
END

INSERT #GetPort
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE', @inst, @inst1

SELECT value FROM #GetPort
DROP TABLE #GetPort


Submitted by Devscripts on 13-02-2003 20:32


Recent Additions (from all categories)

(PHP) T Shirt Printing Software

(PHP) Youtube Video Organizer Script

(PHP) MP3z - MP3 Search Engine Script

(PHP) Recipez- PHP Recipe Script

(ASP) Stop image hotlinking and downloading. Web image protection is easy with Image Trapper.

Top Rated Scripts

(Javascripts) Javascript Delayed Redirection Rating: 5

(PHP) Random Links and images with PHP & MySQL Rating: 5

(PHP) RSS/XML news feed headline grabber! Rating: 5

(PHP) Random Signatures/Avatars Rating: 5

(Javascripts) Detecting Client Web Browser Rating: 5

© Copyright 2003 - Devscripts.net  Web Analytics