{"id":41,"date":"2021-09-02T00:00:00","date_gmt":"2021-09-01T15:00:00","guid":{"rendered":"https:\/\/www.tech-tips.takmaru.com\/?p=5161"},"modified":"2021-09-02T00:00:00","modified_gmt":"2021-09-01T15:00:00","slug":"apache-accesslog-sql-sqlserver","status":"publish","type":"post","link":"https:\/\/www.tech-tips.takmaru.com\/?p=41","title":{"rendered":"Apache \u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092SQL\u3067\u8aad\u307f\u8fbc\u3080\u3010SQL Server\u7de8\u3011"},"content":{"rendered":"<p>Apache \u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\uff08CLF\u5f62\u5f0f\uff09\u3092\u3001SQLServer\u306e <a href=\"https:\/\/docs.microsoft.com\/ja-jp\/sql\/t-sql\/functions\/openrowset-transact-sql?view=sql-server-ver15\">OPENROWSET<\/a> \u3092\u5229\u7528\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30ed\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u76f4\u63a5SQL\u3067\u8aad\u307f\u8fbc\u3093\u3067\u307f\u307e\u3059\u3002<\/p>\n<h2>\u30c0\u30df\u30fc\u30ed\u30b0\u751f\u6210<\/h2>\n<p>\u8aad\u307f\u8fbc\u3080\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u306f <a href=\"https:\/\/mt.orz.at\/archives\/2012\/11\/apacherubygems.html\">apache-loggen<\/a> \u3068\u3044\u3046\u30c0\u30df\u30fc\u30ed\u30b0\u3092\u751f\u6210\u3059\u308b\u30c4\u30fc\u30eb\u3067\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n<figure>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tech-tips.takmaru.com\/wp-content\/uploads\/2026\/03\/image-4-1024x322-2.png\" \/><\/p><figcaption>\n<p>apache-logen<\/p>\n<\/figcaption><\/figure>\n<p>\u3053\u308c\u3092 <strong>c:\\logs\\access_log<\/strong> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u914d\u7f6e\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-apacheconf\">172.171.115.107 - - [02\/Sep\/2021:15:40:27 +0900] &quot;GET \/item\/electronics\/3055 HTTP\/1.1&quot; 200 89 &quot;\/category\/electronics&quot; &quot;Mozilla\/5.0 (Windows NT 6.0; rv:10.0.1) Gecko\/20100101 Firefox\/10.0.1&quot;\n172.117.78.196 - - [02\/Sep\/2021:15:40:27 +0900] &quot;GET \/category\/software HTTP\/1.1&quot; 200 40 &quot;\/category\/games?from=10&quot; &quot;Mozilla\/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident\/5.0)&quot;\n20.93.218.134 - - [02\/Sep\/2021:15:40:27 +0900] &quot;GET \/category\/books HTTP\/1.1&quot; 200 96 &quot;\/item\/electronics\/457&quot; &quot;Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident\/4.0; YTB730; GTB7.2; EasyBits GO v1.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)&quot;\n160.24.194.150 - - [02\/Sep\/2021:15:40:27 +0900] &quot;GET \/category\/electronics HTTP\/1.1&quot; 200 123 &quot;-&quot; &quot;Mozilla\/5.0 (Windows NT 6.1; WOW64) AppleWebKit\/535.7 (KHTML, like Gecko) Chrome\/16.0.912.77 Safari\/535.7&quot;\n72.153.81.37 - - [02\/Sep\/2021:15:40:27 +0900] &quot;GET \/category\/books HTTP\/1.1&quot; 200 62 &quot;-&quot; &quot;Mozilla\/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident\/4.0; YTB730; GTB7.2; EasyBits GO v1.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)&quot;\n<\/code><\/pre>\n<h2>\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210<\/h2>\n<p>OPENROWSET \u3067\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u8aad\u307f\u53d6\u308b\u306b\u3042\u305f\u308a\u3001\u305d\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3092\u5b9a\u7fa9\u3057\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002XML\u5f62\u5f0f\u3068\u975eXML\u5f62\u5f0f\u304c\u3042\u308a\u3001\u4e16\u306e\u4e2d\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u975eXML\u5f62\u5f0f\u304c\u591a\u3044\u306e\u3067\u6562\u3048\u3066\u306eXML\u5f62\u5f0f\u3067\u3084\u3063\u3066\u307f\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u30ec\u30a4\u30a2\u30a6\u30c8\u306b\u3064\u3044\u3066\u306e\u8a73\u3057\u3044\u8aac\u660e\u306f\u4ee5\u4e0b\u3092\u53c2\u7167\u304f\u3060\u3055\u3044\u3002<br \/>\n<a href=\"https:\/\/docs.microsoft.com\/ja-jp\/sql\/relational-databases\/import-export\/xml-format-files-sql-server?view=sql-server-ver15\">XML \u30d5\u30a9\u30fc\u30de\u30c3\u30c8 \u30d5\u30a1\u30a4\u30eb (SQL Server)<\/a><br \/>\n\u4ee5\u4e0b\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092 <strong>c:\\logs\\access_log.fmt<\/strong> \u3068\u3044\u3046\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u914d\u7f6e\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-markup\">&lt;?xml version=&quot;1.0&quot;?&gt;\n&lt;BCPFORMAT\n  xmlns=&quot;http:\/\/schemas.microsoft.com\/sqlserver\/2004\/bulkload\/format&quot;\n  xmlns:xsi=&quot;http:\/\/www.w3.org\/2001\/XMLSchema-instance&quot;&gt;\n &lt;RECORD&gt;\n  &lt;FIELD ID=&quot;1&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;2&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;3&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;N1&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;[&quot; \/&gt;\n  &lt;FIELD ID=&quot;4&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;]&quot; \/&gt;\n  &lt;FIELD ID=&quot;N2&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;5&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;N3&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;6&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;7&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;N4&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;8&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;N5&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot; &quot; \/&gt;\n  &lt;FIELD ID=&quot;N6&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;9&quot;  xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;&amp;quat;&quot; \/&gt;\n  &lt;FIELD ID=&quot;N7&quot; xsi:type=&quot;CharTerm&quot; TERMINATOR=&quot;\\r\\n&quot; \/&gt;\n &lt;\/RECORD&gt;\n &lt;ROW&gt;\n  &lt;COLUMN SOURCE=&quot;1&quot; NAME=&quot;IP&quot;        xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;2&quot; NAME=&quot;IDNT&quot;      xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;3&quot; NAME=&quot;USER&quot;      xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;4&quot; NAME=&quot;DT&quot;        xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;5&quot; NAME=&quot;URL&quot;       xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;6&quot; NAME=&quot;STATUS&quot;    xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;7&quot; NAME=&quot;SIZE&quot;      xsi:type=&quot;SQLNUMERIC&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;8&quot; NAME=&quot;REFERER&quot;   xsi:type=&quot;SQLCHAR&quot;\/&gt;\n  &lt;COLUMN SOURCE=&quot;9&quot; NAME=&quot;USERAGENT&quot; xsi:type=&quot;SQLCHAR&quot;\/&gt;\n &lt;\/ROW&gt;\n&lt;\/BCPFORMAT&gt;\n<\/code><\/pre>\n<p>\u3044\u304f\u3064\u304b\u30b3\u30c4\u304c\u3042\u308b\u306e\u3067\u8aac\u660e\u3057\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3067\u306f\u3001CSV\u5f62\u5f0f\u3067\u3042\u308b\u3088\u3046\u306a\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u3067\u56f2\u3093\u3060\u6587\u5b57\u5217\u306e\u5b9a\u7fa9\uff08\u6587\u5b57\u5217\u306e\u4e2d\u306b\u533a\u5207\u308a\u8a18\u53f7\u304c\u73fe\u308c\u3066\u3082\u7121\u8996\u3059\u308b\uff09\u306b\u5358\u7d14\u306b\u5bfe\u5fdc\u3067\u304d\u307e\u305b\u3093\u3002\u533a\u5207\u308a\u6587\u5b57\u306f\u53d6\u308a\u51fa\u3059\u30c8\u30fc\u30af\u30f3\u5358\u4f4d\u3067\u90fd\u5ea6\u8a2d\u5b9a\u3059\u308b\u306e\u3067\u3001\u3053\u3061\u3089\u3092\u5229\u7528\u3057\u3066\u30c8\u30fc\u30af\u30f3\u3092\u300c\u5207\u308a\u6368\u3066\u308b\u300d\u3053\u3068\u3067\u5fc5\u8981\u306a\u6587\u5b57\u5217\u306e\u307f\u3092\u53d6\u308a\u51fa\u3057\u307e\u3059\u3002\u4f8b\u3048\u3070\u300cAA,&#8221;BB,CC&#8221;\u300d\u3067\u3042\u308c\u3070\u3001\u7b2c\u4e00\u30c8\u30fc\u30af\u30f3\u306f\u30b3\u30f3\u30de(,)\u307e\u3067\u3001\u7b2c2\u30c8\u30fc\u30af\u30f3\u3001\u7b2c3\u30c8\u30fc\u30af\u30f3\u306f\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3(&#8220;)\u3092\u7d42\u7aef\u3068\u3057\u3066\u7b2c2\u30c8\u30fc\u30af\u30f3\u306f\u5207\u308a\u6368\u3066\u308b\u3001\u3068\u3059\u308b\u3053\u3068\u3067\u300cAA\u300d\u3068\u300cBB,CC\u300d\u3092\u53d6\u308a\u51fa\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<br \/>\n\u5c1a\u3001\u30c0\u30d6\u30eb\u30af\u30a9\u30fc\u30c6\u30fc\u30b7\u30e7\u30f3\u306f\u3001XML\u4e0a\u306f\u4e88\u7d04\u6587\u5b57\u3067\u3059\u306e\u3067\u3001\u30a8\u30b9\u30b1\u30fc\u30d7\u6587\u5b57\uff08&quat;\uff09\u3067\u8868\u73fe\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u306e\u3067\u3054\u6ce8\u610f\u304f\u3060\u3055\u3044\u3002<\/p>\n<h2>OPENROWSET \u306b\u3088\u308b\u8aad\u307f\u8fbc\u307f<\/h2>\n<p>\u4f5c\u6210\u3057\u305f\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u4f7f\u3063\u3066\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u8aad\u307f\u8fbc\u3093\u3067\u307f\u307e\u3059\u3002<\/p>\n<pre><code class=\"language-sql\">SELECT T.*\n  FROM OPENROWSET( BULK N'C:\\logs\\access_log'\n     , FORMATFILE=N'C:\\logs\\access_log.fmt' ) AS T;\n<\/code><\/pre>\n<p>\u5b9f\u884c\u7d50\u679c\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\u3002\u304d\u308c\u3044\u306b\u5206\u5272\u3057\u3066\u53d6\u5f97\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n<figure>\n<p><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.tech-tips.takmaru.com\/wp-content\/uploads\/2026\/03\/image-5-1024x160-2.png\" \/><\/p><figcaption>\n<p>\u5b9f\u884c\u7d50\u679c<\/p>\n<\/figcaption><\/figure>\n<p>\u5b9f\u969b\u306b\u80a5\u5927\u5316\u3057\u305f\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u30ed\u30fc\u30c7\u30a3\u30f3\u30b0\u3082\u306a\u3057\u306b\u8aad\u307f\u8fbc\u307f\u305f\u3044\u5834\u9762\u306f\u3042\u307e\u308a\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4e00\u822c\u30d5\u30a1\u30a4\u30eb\u3092\u76f4\u63a5SQL\u3067\u53c2\u7167\u3067\u304d\u308b\u3068\u4fbf\u5229\u306a\u3053\u3068\u3082\u591a\u3044\u3067\u3057\u3087\u3046\u304b\u3089\u899a\u3048\u3066\u304a\u3044\u3066\u640d\u306f\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache \u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\uff08CLF\u5f62\u5f0f\uff09\u3092\u3001SQLServer\u306e OPENROWSET \u3092\u5229\u7528\u3057\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u30ed\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u3053\u3068\u306a\u304f\u3001\u76f4\u63a5SQL\u3067\u8aad\u307f\u8fbc\u3093\u3067\u307f\u307e\u3059\u3002 \u30c0\u30df\u30fc\u30ed\u30b0\u751f\u6210 \u8aad\u307f\u8fbc\u3080\u30a2\u30af\u30bb\u30b9\u30ed\u30b0 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":5117,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[26,29],"class_list":["post-41","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-database","tag-sql","tag-sqlserver"],"_links":{"self":[{"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=41"}],"version-history":[{"count":0,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/posts\/41\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=\/wp\/v2\/media\/5117"}],"wp:attachment":[{"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tech-tips.takmaru.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}