Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 21st, 2004, 02:25 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to check TCPIP Port Number for SQL Sever

Hi all,

How to check SQLServer TCPIP port number?

Thanks

John

 
Old October 21st, 2004, 03:52 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

Is there a particular method you will like to use?

Jaime E. Maccou
Applications Analyst
 
Old October 21st, 2004, 04:17 PM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I need to know as many ways as possible.

Thanks

 
Old October 21st, 2004, 06:03 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

launch the Server Network Utility from the server in question and click Properties in the TCP/IP entry in the Enabled protocols list. You can also check the port number an instance of SQL Server is using by looking in the error log for the specific instance. You should see an entry in the error log that looks like this:
SQL server listening on 127.0.0.1: 1362.

Jaime E. Maccou
Applications Analyst
 
Old October 22nd, 2004, 08:57 AM
Authorized User
 
Join Date: Oct 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Jaime,

Thanks for you help. However, I am using Window XP Pro- not a server version. Can you tell me how to do that? Are there any way to change it to different port? The reason to ask this question is: durring the interview, They asked me this question although I am just a developer, not a DBA.

Thanks alot.

John Dang

 
Old October 22nd, 2004, 10:31 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

A real developer would do it via code, not use some namby-pamby UI :)
Save the following to a file SqlServerPort.js and run from command prompt with:
CScript SqlServerPort.js

Code:
// View and change SQL Server's TCP port number
function getSqlServer(Name, User, Password)
{
  var oServer = new ActiveXObject("SQLDMO.SQLServer");
  oServer.Connect(Name, User, Password);
  return oServer;
}

function getTcpPortNumber(Server)
{
  return Server.Registry.TcpPort;  
}

function setTcpPortNumber(Server, PortNumber)
{
  Server.Registry.TcpPort = PortNumber;
}

function tryClose(Server)
{
  try
  {
    Server.Close();
  }
  catch(e)
  {
    //
  }
}

function showUsage()
{
  WScript.echo("CScript SqlServerPort.js SqlServerName UserName Password [New Port Number]");
}

function main()
{
  var colArgs = WScript.Arguments;
  if (colArgs.length < 3)
  {
    showUsage();
    WScript.quit();
  }
  try
  {
    var oServer = getSqlServer(colArgs(0), colArgs(1), colArgs(2));
  }
  catch(e)
  {
    WScript.echo("Unable to connect to server.\n" + e.message + " (" + e.number + ")");
    WScript.quit();
  }
  try
  {
    var iPortNumber = getTcpPortNumber(oServer);
    WScript.echo("Server '" + colArgs(0) + "' using TCP port number: " + iPortNumber);
  }
  catch(e)
  {
    WScript.echo("Unable to find port number.\n" + e.message + " (" + e.number + ")");
    tryClose(oServer);
    WScript.quit();
  }
  if (colArgs.length == 4)
  {
    try
    {
       iNewPortNumber = Math.floor(colArgs(3));
       if (!isNaN(iNewPortNumber) && iNewPortNumber > 0 && iNewPortNumber < 65536) 
       {
         setTcpPortNumber(oServer, iNewPortNumber);
         WScript.echo("TCP port now set to: " + iNewPortNumber);
       }
       else
       {
         WScript.echo("Invalid port number, port remains at: " + iPortNumber);
       }
     }
    catch(e)
    {
      WScript.echo("Unable to set port number to '" + colArgs(3) + "'.\n" + e.message + " (" + e.number + ")");
    }
  }
  tryClose();
  WScript.echo("Done.");
  WScript.quit();
}

main();
Only for SQL Server 2000, the username/password need to be that of a sysadmin.

--

Joe
 
Old October 22nd, 2004, 04:00 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to jemacc
Default

That is this real sharp.

Is it possible you can look at this post and offer a solution or another script that may be able to accomplish the task.

http://p2p.wrox.com/topic.asp?TOPIC_ID=21004

Your help will be greatly appreciated

Jaime E. Maccou
Applications Analyst





Similar Threads
Thread Thread Starter Forum Replies Last Post
Port Number Indraja Forum and Wrox.com Feedback 1 May 25th, 2007 03:11 AM
SQL Sever pushpa All Other Wrox Books 0 February 22nd, 2007 07:01 AM
How to UnBlock Port number in WinXP? ashu_from_india General .NET 0 November 3rd, 2006 08:44 AM
edit 80 port number AristotleYu ASP.NET 2.0 Basics 0 June 22nd, 2006 11:36 AM
Do i have 2 specify the path a SQL sever is to use chiefouko SQL Server 2000 1 July 17th, 2003 06:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.