Re: Finding and Identifing SQL Servers
- From: K. Lindner <KLindner@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 12 Mar 2008 09:57:04 -0700
Here's a bit of a hack to get you started. I've taken some of the
serverproperty values mentioned by Dimant and stuck them in a batch file that
accepts a servername. The batch file tries to open a trusted connection to
the server passed and dumps the results to {servername}.txt.
Please give this a good look and treat it as a demo of an approach that
might work for your circumstances.
From command line:sqlcmd /L > servers.txt
Open servers.txt. Remove everything (including whitespace) so that only
server names exist.
In front of each server name add: call checksql.bat{space}
If servers.txt looks like this:
Servers:
DEV01
DEV01\SYSTEMCENTER
SQL01
SQL02
You should edit, so it looks like this:
call checksql.bat DEV01
call checksql.bat DEV01\SYSTEMCENTER
call checksql.bat SQL01
call checksql.bat SQL02
Now that the edit is complete, save servers.txt as queryservers.bat.
Next, save the following as checksql.bat. It needs to be in the same folder
you saved queryservers.bat. This is a one line batch file so whatever you're
editor (eg, notepad), make sure that Word Wrap or Wrap Lines is off.
sqlcmd -W -h-1 -o"%1.txt" -S%1 -E -Q"set nocount on; if charindex('sql
server 2005', @@version) > 0 begin select SERVERPROPERTY('ServerName') AS
[ServerName], replace(replace(@@version, char(13), ''), char(10), '') AS
[Server Information], SERVERPROPERTY('MachineName') AS [MachineName],
SERVERPROPERTY('InstanceName') AS [InstanceName],
SERVERPROPERTY('productversion') AS [ProductVersion],
SERVERPROPERTY('ProductLevel') AS [ProductLevel], SERVERPROPERTY('Edition')
AS [Edition], SERVERPROPERTY('Collation') AS [Collation],
SERVERPROPERTY('IsClustered') AS [IsClustered],
SERVERPROPERTY('IsFullTextInstalled') AS [IsFullTextInstalled],
SERVERPROPERTY('IsIntegratedSecurityOnly') AS [IsIntegratedSecurityOnly],
SERVERPROPERTY('LicenseType') AS [LicenseType], SERVERPROPERTY('NumLicenses')
AS [NumLicenses] end else begin select @@servername as [ServerName],
replace(replace(@@version, char(13), ''), char(10), '') as [Server
Information] ; end"
Finally, run queryservers.bat. You should end up with text files in the
directory from which you're running queryservers.bat.
Good luck! :)
.
- Follow-Ups:
- Re: Finding and Identifing SQL Servers
- From: Stacey
- Re: Finding and Identifing SQL Servers
- References:
- Re: Finding and Identifing SQL Servers
- From: Uri Dimant
- Re: Finding and Identifing SQL Servers
- Prev by Date: Re: user permissions
- Next by Date: Re: Finding and Identifing SQL Servers
- Previous by thread: Re: Finding and Identifing SQL Servers
- Next by thread: Re: Finding and Identifing SQL Servers
- Index(es):
Relevant Pages
|
|