How to specify port in four-part SQL Server names? - sql-server

I find in Microsoft's own SQL Server documentation a very brief explanation of multipart names (server.database.schema.object) -- see link to Transact-SQL syntax conventions. However, I do not find there any information or an example of specifying a port when something other than the default port is used by the targeted SQL Server instance.
I did find elsewhere an example with named instance, like "server\instance".db.schema.table, but what if I know only the port number, not any instance name?
How do I indicate the SQL Server instance's port number in the four-part name server.db.schema.table? Can you please provide an example? Thanks.

Related

All well known aliases for localhost?

The primary goal is determine whether machine is local or remote by machine name.
I have to complete a list with all well known aliases of localhost.
So here I am:
var localAddressList = new List<string>
{
#"(local)",
// #"(localdb)",
#"(localhost)",
#"localhost",
// #"localhost -4",
// #"localhost -6",
#"127.0.0.1",
#"::1",
#"."
};
But I am not sure about commented aliases.
Do you know another aliases ?
Can anyone share with me where to find this information ?
You can check your DNS Server definitions and your SQL Server Aliases definitions.
SQL Browser will check for SQL Server hostname and aliases.
Inside Sql Server Configuration Manager go to SQL Native Client XX.0 Configuration (XXbit) then Aliases section.
Also any computer with a modified hosts file or another DNS Server could address the server with another name (this does not mean SQL Browser will answer properly though).
Make sure to check the following file it might contain your desires :
C:\WINDOWS\system32\drivers\etc\hosts

Using qXL library to query a table from kdb+ server instance

Has anyone had experience on using the qXL library to query a table from kdb+ server instance? The example provided in Github is for the local kdb+ instance rather querying a server instance.
I haven't used it, but the example at the bottom of the page you referenced suggests that you can specify a host IP as a string:
=qRtdOpen("testRTDConnection","10.10.4.205",17010)
The API documentation states:
hostname [String] - name or IP address of the host to which connection should be opened

How to connect to MS-SQL 2012 and MS-SQL 2008 on same machine

I have a an application where you can log on to either MS-SQL 2012 and MS-SQL 2008.
Fields that can be defined are:
Server IP
Database Name
User Id and Password
Schema Prefix
Previously I had no issues with this.
Now I am puzzled.
I am told MS-SQL 2012 and MS-SQL 2008 are on same box with same IP.
I googled this arrangement and it is quite OK to do that.
I have no mental picture of how connecting to one or both of these servers might be carried out.
Are these two installs folded into one? Do they listen on the same port 1433?
Should I be able to access using just the 4 fields I can specify?
Server IP,Database Name, User Id and Password and Schema Prefix.
Help if you can, please ;-)
Tony
No, that is not enough information to reach separate SQL Server instances on the same server.
When installing multiple instances of SQL Server, only one instance can be a default instaince, the other instances have to be named instances. Thus, you also need the instance name to reach one of the databases.
However, if the IP address is not strictly only an IP address but a string, you can include the instance name. Example:
123.14.314.73\sql2012
(Note: IP addreses with components above 255 are reserved for examples and movies. ;) )

Understand Sql Server connectionstring for asp.net

I am trying to understand the differences between the following 2 connectionstrings.
one uses servername\instancename and the other one uses the server ip address.
Can I specify port number for "serverName\instanceName".
I know you can specify port number for ip address, something like '10.0.0.1,xxx'.
thanks,
Server=myServerName\theInstanceName;Database=myDataBase;Trusted_Connection=True;
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Quite briefly:
if you have just server=(machinename) or server=(ipaddress) then you're connecting to the default instance of SQL Server on that machine (no name for the instance)
if you have server=(machinename)\InstanceName, then you're connecting to a named instance of SQL Server on that machine
Each physical server machine can have one default instance of SQL Server, and any number of named instances (names must be different, obviously).
To connect to a named instance and specify a non-standard port, use this syntax here:
server=(machinename)\InstanceName,xxxx
or
server=(ip-address)\InstanceName,xxxx
where the xxxx stands for the port you want to use.
Mostly, its unimportant if you don't have duplicate instances.
For example, SQL supports multiple instances on the same box as a way of isolating running instances. Most of the time, you will never do this, and thus can get away with using the IP address in the connection string. If for some reason, you need to run multiple instances of SQL server on the same machine, you need to specify which instance you actually want to connect to.
This covers it in more detail.

SQL Server, convert a named instance to default instance?

I need to convert a named instance of SQL server 2005, to a default instance.
Is there a way to do this without a reinstall?
The problem is, 2 out of 6 of the developers, installed with a named instance. So its becoming a pain changing connection strings for the other 4 of us. I am looking for the path of least resistance to getting these 2 back on to our teams standard setup.
Each has expressed that this is going to be, too much trouble and that it will take away from their development time. I assumed that it would take some time to resolve, in the best interest of all involved, I tried combing through configuration apps installed and didn't see anything, so I figured someone with more knowledge of the inner workings would be here.
I also wanted to convert a named instance to default - my reason was to access it with just the machine name from various applications.
If you want to access a named instance from any connection string without using the instance name, and using only the server name and/or IP address, then you can do the following:
Open SQL Server Configuration Manager
Click SQL Server Network Configuration
Click Protocols for INSTANCENAME you want to make available (i.e. SQLExpress)
Right-click TCP/IP and click Enabled
Right-click TCP/IP and go to Properties
Go to the IP Addresses tab
Scroll down to the IPAll section
Clear the field TCP Dynamic Ports (i.e. empty/blank)
Set TCP Port to 1433
Click Ok
Go to SQL Server Services
Right-click your SQL Server (INSTANCENAME) and click Restart
This will make the named instance listen on the default port. Note : You can have only one instance configured like this - no two instances can have same port on the IP All section unless the instance is a failover cluster.
As far as I know, no. One reason is the folder structure on the hard drive; they will have a name like MSSQL10.[instancename]
This is why a lot of companies store their applications' connection strings at the machine level instead of the application level.
Just take the connection string out of the source code entirely. Then have everyone put their connection string in their machine.config.
This has the added benefit of avoiding unnecessary app-specific environment logic, i.e. when you copy your application to the staging server, the staging server already "knows" what database to use.
The only way to change the instance name is to re-install - uninstall and install as default instance.
A lot of times I'll use client alias to point an application at a different sql server than the ones it's connection string is for, esp. handy when working on DTS or an application with a hard coded connection string. Have everybody use a commonly named alias, use the alias in the connection string and point the alias’s on each dev box to the to the different instances. That way you won't have to worry about if the server is the default instance or not.
You shouldn't ever really need to do this. Most software that claims to require the default instance (like Great Plains or Dynamics) doesn't actually.
If you repost with your situation (installed X, then Y, but need to accomplish Z) I bet you'll get some good workarounds.
I think you can migrate your data from Sql Server without having default instance installed. You can just specify the port number of your Sql Server instance in Oracle Sql Developer and you can connect just using the server name, not using the server name and the instance.
Like this:
connect to "MYSERVER, 1433"

Resources