How to figure out all the instances on sql server?
I am connected to one instance of the database server. How will i come t开发者_如何学JAVAo know if there are any other instances on the same server and their names?
First go to Start >> Run >> CMD (Open command prompt). Once in command prompt run following command based on SQL Server version installed on local machine.
For SQL Server 2000:
C:\> isql -L
For SQL Server 2005 / SQL Server 2008:
C:\> osql -L
OR
C:\> sqlcmd -L
As SQL script below is the snippet - Source
This script requires execute permissions on XP_CMDShell.
CREATE TABLE #servers(sname VARCHAR(255))
INSERT #servers (sname)
EXEC master..xp_CMDShell 'ISQL -L'
DELETE
FROM #servers
WHERE sname='Servers:'
OR sname IS NULL
SELECT LTRIM(sname)
FROM #servers
DROP TABLE #servers
精彩评论