Created
January 6, 2011 03:45
-
-
Save zippy1981/767476 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- | |
-- Ad Hoc IIS Log analysis | |
-- Based on code from http://support.microsoft.com/kb/296085 | |
-- Updated to work with the IIS log column config from my | |
-- particular inherited Windows 2008 server. | |
-- | |
DROP TABLE #IISLogs | |
GO | |
CREATE TABLE #IISLogs ( | |
[date] [datetime] NULL, | |
[time] [datetime] NULL , | |
[s-sitename] [varchar] (50) NULL , | |
[s-computername] [varchar] (50) NULL , | |
[s-ip] [varchar] (50) NULL , | |
[cs-method] [varchar] (50) NULL , | |
[cs-uri-stem] [varchar] (255) NULL , | |
[cs-uri-query] [varchar] (2048) NULL , | |
[s-port] [int] NULL , | |
[cs-username] [varchar] (50) NULL , | |
[c-ip cs-version] [varchar] (50) NULL , | |
[cs(User-Agent)] [varchar] (255) NULL , | |
[cs(Cookie)] [varchar] (2048) NULL , | |
[cs(Referer)] [varchar] (2048) NULL, | |
[cs-host] [varchar] (2048) NULL , | |
[sc-status] [varchar] (50) NULL , | |
[sc-substatus] [varchar] (50) NULL , | |
[sc-win32-status] [varchar] (50) NULL , | |
[sc-bytes] [bigint] NULL , | |
[cs-bytes] [int] NULL , | |
[time-taken] [varchar] (50) NULL , | |
); | |
BULK INSERT #IISLogs FROM 'F:\logs\W3SVC3\u_ex110104.log' | |
WITH ( | |
FIELDTERMINATOR = ' ', | |
ROWTERMINATOR = '\n', | |
MAXERRORS = 1000 | |
); | |
SELECT TOP 5 * FROM #IISLogs WHERE [cs-uri-stem] LIKE '%.ashx' | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment