March 25, 2009 at 5:18 pm
March 25, 2009 at 6:03 pm
well, if you run the script below, it will read the registry and tell you teh listening port...
i duoubt this will work over a linked server, which is what i assume you mean by a remote server?
CREATE TABLE #GetPort
(
token varchar(100),
value varchar(20))
go
DECLARE @inst varchar(200)
DECLARE @inst1 varchar(100)
--Determine registry path and key
IF(charindex('\',@@servername) > 0)
BEGIN
SELECT @inst = substring(@@servername,charindex('\',@@servername) ,50)
SELECT @inst = 'SOFTWARE\Microsoft\Microsoft SQL Server'+@inst+'\MSSQLServer\SuperSocketNetLib\Tcp'
--SELECT @inst1 = 'TcpDynamicPorts'
SELECT @inst1 = 'TcpPort'
END
ELSE
BEGIN
if SUBSTRING(@@VERSION,23,1) = '7'
begin
SELECT @inst = 'SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib\VIA'
SELECT @inst1 = 'DefaultServerPort'
end
else
begin
SELECT @inst = 'SOFTWARE\Microsoft\MSSQLServer\Client\SuperSocketNetLib\Tcp'
SELECT @inst1 = 'DefaultPort'
end
END
print @inst + '\\\\////'+ @inst1
INSERT #GetPort
EXEC master..xp_regread 'HKEY_LOCAL_MACHINE', @inst, @inst1
SELECT substring(@@servername,1,25) as ServerName, value as port FROM #GetPort
DROP TABLE #GetPort
Lowell
March 26, 2009 at 11:54 am
Thank you both for the idea and scrpit. I am working on this..
I understand that the script given will work if I am connected to server only. However the issue is I can not connect to the servers. So I need to run this (similer) code against all servers (name will be found in a table) using some batch
If you have furher idea.. plz share
Thanks again
March 26, 2009 at 12:08 pm
i tried running the command over a linked server; basically i tried changing the last command to a 4 part command:
EXEC linkedservername.master..xp_regread 'HKEY_LOCAL_MACHINE', @inst, @inst1
got this error:
SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\SuperSocketNetLib\Tcp\\\\////TcpPort
Msg 7411, Level 16, State 1, Line 43
Server 'db1' is not configured for RPC.
maybe if RPC was enabled for the server, but i dunno...it's getting out of my area of knwoledge.
i think you'll have to do this in a programming language, or use RegEdit to connect to the remote machines using your domain credentials manually.
you could also try SQLRecon.exe, which scans a network for servers and reports back a lot of information, but it is not possible via a linked server.
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply