Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Connect to server from script?

Author  Topic 

jdblack
Starting Member

11 Posts

Posted - 2010-11-03 : 12:39:37
Is there any command or method of connecting to a SQL instance without doing it through the GUI?

I've got about 100 servers with multiple SQL instances. I'd like to make a script that takes a server name & figures out the correct instance to connect to.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-03 : 12:41:40
Not sure if this helps you, but I register my servers into special groups and save the credentials (if using SQL auth). So I don't need to know type in the names at all. I just locate it in my registrations and expand it.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

jdblack
Starting Member

11 Posts

Posted - 2010-11-03 : 12:47:19
Doesn't help for this task, but thanks for the suggestion. The SQL server names aren't constant; at least a few servers are brought up and taken down each week by IT, and before connecting to the new servers we don't know which port/instance from a list of possibilities is the one we want. The queries will also potentially be run on 20+ revolving laptops/desktops in different countries owned by various people who don't know SQL. For those reasons this query (and others they use) are stored on a file share.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-03 : 13:06:40
Could you instead use a DNS alias? That way you can control what server they'll connect to, but they'll always use the same name(s).

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-11-03 : 13:06:55
Or a GSS?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -