Geeks With Blogs
Welcome to
Geeks with Blogs
Login
Ralph Willgoss
My Other Recent Posts
Continuous Monitoring with CruiseControl.Net
Resharper 3.0.x not recognised under Visual Studio 2008 Beta 2
Error installing .Net 1.1 "Error: internal error 2709 feature GUID for use by Cartman"
Setting up an ASP.NET Website Development environment using Visual Studio .NET, Subversion and Windows XP
Setting up an ASP.NET Website Development environment using Visual Studio .NET, Subversion and Windows XP
In the beginning....
Post Categories
General
XNA
Rant
Videos
PowerShell
Astronomy
Service Manager
Archives
December 2020 (1)
October 2020 (2)
June 2020 (1)
September 2019 (1)
January 2014 (1)
November 2012 (3)
December 2010 (1)
June 2008 (1)
August 2007 (1)
December 2006 (1)
August 2006 (1)
October 2005 (1)
July 2005 (1)
Load "BLOG", 8, 1
This is the best I could do on short notice.
<< How do I recycle an IIS App pool with Powershell?
|
Home
|
Troubleshooting "Access is denied" when trying to run Enable-PSRemoting >>
How do I programatically determine which port a SQL Server is running on?
Comments
|
Share
How do I programatically determine which port a SQL Server is running on?
/*
Wrapper script for xp_readerrorlog
Author: Ralph Willgoss
Date: 2nd Oct 2012
This script cycles through all logs files, looking for the listening port.
Normally you have to specify the log file one by one, the script removes the need for that.
Param ref for: xp_readerrorlog
1. Value of error log file you want to read: 0 = current, 1 = Archive #1, 2 = Archive #2, etc...
2. Log file type: 1 or NULL = error log, 2 = SQL Agent log
3. Search string 1: String one you want to search for
4. Search string 2: String two you want to search for to further refine the results
5. Search from start time
6. Search to end time
7. Sort order for results: N'asc' = ascending, N'desc' = descending
*/
USE Master
GO
-- Get log count
DECLARE @logcount int
DROP TABLE #Result
CREATE TABLE #Result (ArchiveNo int, Date datetime, Size int)
INSERT INTO #Result
EXEC xp_enumerrorlogs
SET @logcount = (SELECT COUNT(*) FROM #Result)
-- Search the available logs
DECLARE @counter int
SET @counter = 0
WHILE @counter <= @logcount
BEGIN
EXEC xp_readerrorlog @counter, 1, N'Server is listening on', 'any', NULL, NULL, N'asc'
SET @counter = @counter + 1
END
GO
Posted on Monday, November 26, 2012 8:16 PM
SQL Server
|
Back to top
Related Posts on Geeks With Blogs
Matching Categories
Enable Transparent data encryption on SQL Server I...
SQL Server
SQL Server: Moving DATA and LOG file to different ...
SQL Server
importing ssis flat files in redshift using copy
SQL Server
creating a t-sql script to enable query store and ...
SQL Server
Database Enums
SQL Server
Comments on this post: How do I programatically determine which port a SQL Server is running on?
No comments posted yet.
Your comment:
Title:
Name:
Email: (never displayed)
(will show your
gravatar
)
Comment:
Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
Verification:
Copyright © Ralph Willgoss | Powered by:
GeeksWithBlogs.net
Popular Posts on Geeks with Blogs
0
Code Monkey Projectiles - Index
Kindle days are gone and amazon is not gonna accept it.
Geeks With Blogs Content Categories
ASP.Net
SQL Server
Apple
Google
SharePoint
Windows
Visual Studio
Team Foundation Server
Agile
Office
Design Patterns
Web
Azure
Brand New Posts on Geeks with Blogs
0
Kindle days are gone and amazon is not gonna accept it.
How do you run multiple instances of Microsoft Teams?
Benefits of Apple Cider Vinegar
Shaking down the Raspberry Pi 400
Blog is Moving