My enterprise uses a company-wide management to all SQL Server instances, which causes all servers are named with similar name but hard to memorize their function, like
server_11001_sqlserver.company.com for development
server_11002_sqlserver.company.com for production
server_11003_sqlserver.company.com for another team production
server_11015_sqlserver.company.com for my team backup etc.
I need some way to clearly distinguish them such like building custom alias, which might be only visible to myself, in SSMS, to make development work easier. However, creating alias via configuration manager is not allowed for various reasons.
Are there any alternative ways?
create or delete a server alias in SQL Server by using SQL Server Configuration Manager.
Expand SQL Server Native Client Configuration in SQL Server Configuration Manager, click Aliases, and then choose New Alias from the context menu.
Type the alias name in the Alias Name box. Client apps connect using this name.
Enter a server's name or IP address in the Server box. A named instance's instance name should be appended.
Select the protocol that this alias uses in the Protocol box. The Port No, Pipe Name, or Connection String title of the optional attributes box changes when a protocol is chosen.
Programmers who build their own connection strings may find the connection strings provided in the SQL Server Configuration Manager Help to be helpful. Press F1 to retrieve this data in the New Alias dialog box.
Related
So, I have a SQL Server connection string that points at a local database:
Data Source=.;Initial Catalog=MyDatabase;Integrated Security=True
I cannot change this connection string, but I would love for the SQL server to live elsewhere.
Is there some way - either with SQL Server or with something in the Operating System to make this possible? I know that the Integrated Security (aka. Windows Authentication) part will make this really hard, but I figure it's worth asking in case there is a way.
If the client software uses the native SQL client (and almost everything does) you can alias any server name using the SQL Server Configuration Manager. In the Configuration Manager snap-in, expand the "SQL Native Client [version] Configuration" item, right-click "Aliases" and choose "New Alias..." There are two such items, for 32-bit and 64-bit, don't forget to add the alias to both places.
Use this power sparingly. Any server name includes special names like . and (LocalDB)\MyInstance, which normally refer only to the local machine and don't even use TCP/IP. Aliasing these can be very confusing to a casual reader. The alias is not case-sensitive, but it must otherwise match exactly, so adding blanks or using things like localhost instead of . will defeat it.
I installed SQLEXPRADV_x64_ENU, i can connect to sql server management and query my database, but when i want to add a new ado.net entity data model my server name dropdown is empty.
I get entity framework 6.x from nuget.
The server name depends on how you installed SQLExpress. Two possible configurations for the instance:
Default instance:
You named it, and Hopefully enough you can address it with "." as name for the server.
Named instance (chosen by default):
The Server is called SQLEXPRESS, try and type it as the Server name and see if something happens.
Source: http://www.soheib.com/technical-knowledge/sql-server-2012-express-installation-tutorial/
I am using SQL Server Management Studio 2012.
When I want to connect to a server, the "Connect to Server" dialogue box appears.
In that dialogue, there's a drop down list of all the possible servers.
I have lots of different IP addresses dependant on which server I want to connect to...
Is there any way of giving these IP addresses an alias ?
eg. instead of 219.115.213.81 I could have "My test DB"
Thanks,
Scott
Add an Alias in the SQL Client configuration you will be able to connect via the alias you give it. For example if you want to connect to 192.168.0.45 using the name Bertie set a new alias with and Alias Name of Bertie and a Server of 192.168.0.45 (don't worry about ports if you are using the defaults). Then in SSMS you can connect to Bertie
Each member of our development team has a copy of our application's database running on a local version of SQL Server 2008 Enterprise with SP1. Everyone is able to access the database by specifying their server and instance name in their web.config file, but to best share the developer version of our web.config file, we have standardized on making connections strings generic by using integrated security and setting server property to (local). This strategy is working fine for the majority of our 64-bit Windows 7 machines but in few cases (local) isn't recognized. We have compared settings via the SQL Server Configuration Manager (namely ensuring that the named pipes protocol was enabled) and we've tried setting the "(local)" alias via SQL Server Client Network Utility, but we haven't any luck. What needs to be done in order to use (local) in our connections strings?
Trying changing the Pipe Name for your instance to "\.\pipe\sql\query".
You can find that setting by starting SQL Server Configuration Manager, and navigating to SQL Server Network Configuration > Protocols for (Instance Name) and right-clicking on Named Pipes and selecting Properties. If Named Pipes is not enabled, be sure to enable it before restarting the SQL Server service (see comment by #NoahHeldman).
When connecting to the default instance (that is, without an instance name), SQL Server uses the default port of 1433 and the default pipe name of "\.\pipe\sql\query". Changing it back to match should (hopefully) fix it.
Those machines where the database connection as (local) doesn't work is probably that way because during the database installation, the instance name was set to something specific, rather than the default of "default instance". You can change these instance names, which may resolve this issue: http://coderjournal.com/2008/02/how-to-change-instance-name-of-sql-server/.
I think this occurs when you have SQL Server Express already installed and running, and then install SQL Server Developer Edition / Standard / etc....not 100% sure though, but from what I recall, that may be the case.
I have two development teams, that come from different groups.
Group A develops against a local default instance of Sql Server 2008 R2;
Group B develops against a local named instance of Sql Server 2008 R2.
Is there a way to setup an alias such that both groups are coding against the same name? As it stands right now we have a war of Connection Strings as group B changes (local) to ./DEV and group A changes it back again?
In SQL Server Configuration Manager, under the SQL server native client configuration section there is a subsection called "aliases" you can add an alias into here that points to your named instance. You just use the alias as if it is the default instance on a server with the name of the alias. We use this exact model and have only one connection string that points to a standard alias. Each developer has the same alias name pointing to their own instance.
Aliasing to a Local SqlExpress Instance
To expand on Ben's answer, I had the specific requirement to alias a connection string pointed at a specific Server Instance, and instead re-route this to our local developer Sql Express instances, i.e. to alias from:
SomeServer\SomeInstance
to
.\SQLExpress
This proved somewhat tricky until I found this link here. My Sql Express instance was running on the standard port 1433 (i.e. adapt to suite)
Enable TCP/IP for SqlExpress
Since aliasing is done via TCP/IP ports, TCP/IP protocol must be enabled. (Opening SqlExpress for remote access isn't necessary if you are working locally).
Using Under Sql Server -> Configuration Tools -> Sql Server Configuration Manager:
At the same time, set the Listen All property to Yes.
Enable LocalHost IP's
Ensure that both IPv4 (127.0.0.1) and IPv6 (::1) localhosts are active and enabled.
On each IP's, Leave the Dynamic Port at zero (as the name suggests, the port will be allocated dynamically). The IPAll Dynamic and TCP Ports are then used globally.
You'll need to restart the MSSQLServer / SqlExpress service to effect the change.
Creating Aliases (32 and 64 bit)
Under the Sql Native Client xx Configurations, this requires simply adding the alias "From" Server\Instance as the Alias Name and the actual server + instance as the Server (i.e. my local SqlExpress instance). I was able to connect via both port 1433, or the dynamic port on IpAll (9876), although saw no reason to use the latter. The aliases must be done for both 32 and 64 bit client configurations.
You should now be able to connect using the aliased SomeServer\SomeInstance via SSMS.
Other Notes
Since I was aliasing to a local instance, I did NOT have to add an alias for the from host, SomeServer to a DNS or LocalHosts. This will likely be required however if you are aliasing to a remote server (plus I guess some other security headaches)
I did not need to have the Sql Browser service running.
So it would seem that the Sql Client configuration takes care of the substitution prior to any network or security steps.
Personally, I'd make them all use the same box.
That said, you can set local aliases per developer's box using SQL Server Client tools.
Anything IP address or server name based (such as hosts file or DNS) will fail because instance names (and ports used) are different