{"id":1202,"date":"2019-10-03T17:48:47","date_gmt":"2019-10-03T16:48:47","guid":{"rendered":"http:\/\/piatkosia.k4be.pl\/wordpress\/?p=1202"},"modified":"2019-10-03T17:48:49","modified_gmt":"2019-10-03T16:48:49","slug":"tych-panstwa-nie-obslugujemy","status":"publish","type":"post","link":"https:\/\/piatkosia.k4be.pl\/wordpress\/2019\/10\/03\/tych-panstwa-nie-obslugujemy\/","title":{"rendered":"Tych pa\u0144stwa nie obs\u0142ugujemy"},"content":{"rendered":"<p style=\"text-align: justify;\" align=\"&quot;justify\">Nie b\u0119d\u0119 ukrywa\u0142a, problem pojawi\u0142 si\u0119 u mnie w pracy. Mamy sobie skrypty SQLowe (w tym przypadku MS SQL). Du\u017co skrypt\u00f3w. S\u0105 one uruchamiane, jak supporter chce &#8222;podnie\u015b\u0107&#8221; wersj\u0119 bazy. Mamy te\u017c w folderze ze skryptami plik runme.bat, kt\u00f3ry posiada co\u015b takiego:<\/p>\n\n\n<!--more-->\n\n\n\n<pre class=\"wp-block-preformatted\">ECHO Executing scripts in the Tables folder. Please wait\u2026\n CD .\\00_Tables\n for %%a in (*.sql) do osql -S \"%server%\" -d \"%database%\" -U %login% -P %password% -i %%a -o ..\\Result\\%%a_Result.txt<\/pre>\n\n\n\n<p>powt\u00f3rzone x razy, per \u015bcie\u017cka.  No i kt\u00f3rego\u015b razu, okazuje si\u0119, \u017ce cz\u0119\u015b\u0107 skrypt\u00f3w si\u0119 nie wykona\u0142a, a pr\u00f3ba uruchomienia paczki zostawi\u0142a takiego \u015bmiecia:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Executing scripts in the Tables folder. Please wait\u2026\n Microsoft (R) SQL Server Command Line Tool\n Version 14.0 NT\n Copyright (c) 2015 Microsoft. All rights reserved.\n Note: osql does not support all features of SQL Server 2017.\n Use sqlcmd instead. See SQL Server Books Online for details.\n usage: osql              [-U login id]          [-P password]\n   [-S server]            [-H hostname]          [-E trusted connection]\n   [-d use database name] [-l login timeout]     [-t query timeout]\n   [-h headers]           [-s colseparator]      [-w columnwidth]\n   [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]\n   [-L list servers]      [-c cmdend]            [-D ODBC DSN name]\n   [-q \"cmdline query\"]   [-Q \"cmdline query\" and exit]\n   [-n remove numbering]  [-m errorlevel]\n   [-r msgs to stderr]    [-V severitylevel]\n   [-i inputfile]         [-o outputfile]\n   [-p print statistics]  [-b On error batch abort]\n   [-X[1] disable commands [and exit with warning]]\n   [-O use Old ISQL behavior disables the following]\n        batch processing\n       Auto console width scaling\n       Wide messages\n       default errorlevel is -1 vs 1\n   [-? show syntax summary]\n Microsoft (R) SQL Server Command Line Tool\n Version 14.0 NT\n Copyright (c) 2015 Microsoft. All rights reserved.\n Note: osql does not support all features of SQL Server 2017.\n Use sqlcmd instead. See SQL Server Books Online for details.\n usage: osql              [-U login id]          [-P password]\n   [-S server]            [-H hostname]          [-E trusted connection]\n   [-d use database name] [-l login timeout]     [-t query timeout]\n   [-h headers]           [-s colseparator]      [-w columnwidth]\n   [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]\n   [-L list servers]      [-c cmdend]            [-D ODBC DSN name]\n   [-q \"cmdline query\"]   [-Q \"cmdline query\" and exit]\n   [-n remove numbering]  [-m errorlevel]\n   [-r msgs to stderr]    [-V severitylevel]\n   [-i inputfile]         [-o outputfile]\n   [-p print statistics]  [-b On error batch abort]\n   [-X[1] disable commands [and exit with warning]]\n   [-O use Old ISQL behavior disables the following]\n        batch processing\n       Auto console width scaling\n       Wide messages\n       default errorlevel is -1 vs 1\n   [-? show syntax summary]\n Microsoft (R) SQL Server Command Line Tool<\/pre>\n\n\n<p style=\"text-align: justify;\" align=\"justify\">i by\u0142o to powt\u00f3rzone tyle razy ile &#8230; skrypt\u00f3w si\u0119 nie wykona\u0142o:) A doszli\u015bmy po logach, bo pliki z logami si\u0119 nie stworzy\u0142y.<br \/>Tym razem nie pope\u0142ni\u0142am b\u0142\u0119du z przysz\u0142o\u015bci wi\u0119c przeczyta\u0142am co mi komunikat b\u0142\u0119du wypisa\u0142:<\/p>\n\n\n<p><strong>Note: osql does not support all features of SQL Server 2017.<br> Use sqlcmd instead. See SQL Server Books Online for details.<\/strong><\/p>\n\n\n<p style=\"text-align: justify;\">Aaa czyli co\u015b jest niewspierane? Dziwne, bo przecie\u017c do tej pory wspierane by\u0142o wszystko. Z drugiej skrypty nie zawiera\u0142y jakich\u015b skomplikowanych rzeczy, kt\u00f3re mog\u0142yby nagle przesta\u0107 by\u0107 wspierane.<\/p>\n<p>No to jedyne co mog\u0142am zrobi\u0107, to zmieni\u0107 w skrypcie osql na sqlcmd. I co, pomog\u0142o? A gdzie tam. To co si\u0119 nie wykonywa\u0142o, to si\u0119 nie wykonywa\u0142o nadal. Jedyne co si\u0119 zmieni\u0142o, to komunikaty o b\u0142\u0119dzie.<\/p>\n\n\n<pre class=\"wp-block-preformatted\">Sqlcmd: 'Tu nazwa pliku': Invalid filename.<\/pre>\n\n\n<p>Aaaa ok. No wi\u0119c zobaczy\u0142am co mu mo\u017ce przeszkadza\u0107 &#8211; por\u00f3wnuj\u0105c nazwy tych co si\u0119 wykona\u0142y z pozosta\u0142ymi. I co? Ano to, \u017ce Tu nazwa pliku.SQL i jego braciszkowie mieli w \u015brodku spacje. A \u017ce by\u0142y przed podkre\u015blnikami to ich nie zauwa\u017cy\u0142am;)\u00a0\u00a0<\/p>\n<p>Uff. Czyli to by\u0142 problem.\u00a0<br \/>Jeszcze \u017ceby r\u0119cznie nie\u00a0 poprawia\u0107 tych nazw to machn\u0119\u0142am sobie taki kawa\u0142ek tooliszcza\u00a0<a href=\"https:\/\/github.com\/Piatkosia\/ScriptFilenameFixer\" target=\"_blank\" rel=\"noopener noreferrer\">tu jest kod<\/a> , kt\u00f3rego rdzeniem jest ten kawa\u0142ek:\u00a0<\/p>\n\n\n<pre class=\"wp-block-code\"><code>var pathes = Directory.GetFiles(DirPath, \"*.*\", SearchOption.AllDirectories);\nforeach (var path in pathes)\n{\n\tif (path.Contains(\" \"))\n\t{\n\t    string filename = Path.GetFileName(path);\n\t\tstring filename_no_space = filename.Replace(\" \", \"\");\n\t\tstring fullOutputPath = path.Replace(filename, filename_no_space);\n\t\tif (!File.Exists(fullOutputPath))\n\t\t{\n\t\t\tFile.Move(path, fullOutputPath);\n\t\t}\n    }\n}<\/code><\/pre>\n\n\n\n<p><strong>Podsumowuj\u0105c. Masz podobny b\u0142\u0105d? Wywal spacje z nazw plik\u00f3w .sql \ud83d\ude42<\/strong><\/p>\n\n\n\n<p>Pozostaje mi \u017cyczy\u0107 ci mi\u0142ego dnia.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Nie b\u0119d\u0119 ukrywa\u0142a, problem pojawi\u0142 si\u0119 u mnie w pracy. Mamy sobie skrypty SQLowe (w tym przypadku MS SQL). Du\u017co skrypt\u00f3w. S\u0105 one uruchamiane, jak<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"https:\/\/piatkosia.k4be.pl\/wordpress\/2019\/10\/03\/tych-panstwa-nie-obslugujemy\/\">Lecim dalej<span class=\"screen-reader-text\">Tych pa\u0144stwa nie obs\u0142ugujemy<\/span> <i class=\"fas fa-angle-right\"><\/i><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,696,645,148],"tags":[619,799,222],"class_list":["post-1202","post","type-post","status-publish","format-standard","hentry","category-bez-kategorii","category-c_sharp-2","category-gmtl","category-sql","tag-gmtl","tag-nazwy","tag-sql","entry"],"_links":{"self":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1202","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/comments?post=1202"}],"version-history":[{"count":5,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1202\/revisions"}],"predecessor-version":[{"id":1207,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/posts\/1202\/revisions\/1207"}],"wp:attachment":[{"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/media?parent=1202"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/categories?post=1202"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/piatkosia.k4be.pl\/wordpress\/wp-json\/wp\/v2\/tags?post=1202"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}