Hello Friends,

Can anyone tell me how to find the list of SQL servers on the local machine...and not the network...

I searched in google but everywhere its for the list of SQL servers on network....I just want my PC SQL server name....

Is it possible to get it?

Thanks in advance
Pooja

If you are using sql server and only have one instance installed then the default name is your computer name. Only when you install extra instances do they need to have actual, unique names supplied and then you can open up the SQL Management tool to view them.

Actually the server name differ from PC to PC...when my colleagues do coding their server name is localhost\SQLexpress but same is not the condition in my PC its only localhost and so their code wont work in my machine and then I have to do the changes according to my SQL server name...and we are not sure what will be the one on clients machine....

what I want to do is get the servername before the database connections proceed...

is it possible to get the localhost name of the same machine....

Hi,

The short hand in SQL for localhost is as follows "<local>" or "." However this is not exactly what you are asking... Looking at your example your colleagues are using SQLExpress edition and you are using something like Developer or Enterprise.

By default, the licenced versions use the "default" instance i.e. your database would be localhost. SQLExpress installs itself as a named instance of SQLExpress. You can install other licened versions and also Sql Express as there own instance as well e.g. localhost\MyServerInstance or Localhost\SQLExpress and they would be independent of each other.

Off the top of my head I'm not sure how in code you could gather the various instances of SQL on your machine (as they are independant of each other) Normally I put a config screen or an ini file to configure my SQL connection but it still depends on knowing what instances you have...

This link may help at connection time Click Here

G_Waddell - I browsed through the link but it shows various connections for instance and the local host...

I just want to display the SQL server available on the local machine in a combo box or a list box...

Can anyone tell me how to get the SQL server name from the local machine...no using database connection...and no network servers...
I tried seraching everything...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.