{"id":3471,"date":"2022-04-22T23:06:34","date_gmt":"2022-04-23T07:06:34","guid":{"rendered":"https:\/\/www.gudusoft.com\/?p=3471"},"modified":"2026-07-11T22:56:12","modified_gmt":"2026-07-12T06:56:12","slug":"sql-formatter-web-service","status":"publish","type":"post","link":"https:\/\/www.gudusoft.com\/fr\/service-web-de-formatage-sql\/","title":{"rendered":"Service Web de formatage SQL"},"content":{"rendered":"<p><\/p>\n\n\n<h3 class=\"wp-block-heading\">Informations mises \u00e0 jour (2022)<\/h3>\n\n\n\n<p>Il s&#039;agit d&#039;un article \u00e9crit en 2006 et publi\u00e9 sur <a href=\"https:\/\/www.codeguru.com\/csharp\/sql-formatter-web-service\/\" class=\"rank-math-link\">codeguru<\/a> La technologie utilis\u00e9e dans cet article peut \u00eatre obsol\u00e8te. Si vous recherchez un bon formateur SQL utilisable dans vos programmes Java ou .NET, veuillez consulter [lien\/r\u00e9f\u00e9rence]. <a href=\"https:\/\/sqlparser.com\/features\/sql-formatter.php\" class=\"rank-math-link\">consultez cette page<\/a> En revanche, si vous recherchez un formateur de requ\u00eates SQL gratuit et performant, veuillez consulter\u2026 <a href=\"https:\/\/www.dpriver.com\/pp\/sqlformat.htm\" class=\"rank-math-link\">Formateur SQL instantan\u00e9.<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Introduction<\/h3>\n\n\n\n<p>Le code SQL est bien plus facile et rapide \u00e0 lire et \u00e0 comprendre lorsqu&#039;il est format\u00e9, surtout lorsqu&#039;il s&#039;agit d&#039;une requ\u00eate longue et complexe, ou lorsqu&#039;il faut lire le code d&#039;un tiers. \u00c9crire un formateur SQL performant n&#039;est pas chose ais\u00e9e. Dans cet article, je vais cr\u00e9er un formateur SQL en ligne pour C#. Cette application cliente envoie du SQL non format\u00e9 au serveur, qui lui renvoie le SQL format\u00e9.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Utilisation du code<\/h3>\n\n\n\n<p>Un service Web \u00e0&nbsp;<a href=\"https:\/\/www.gudusoft.com\/fr\/\">www.gudusoft.com<\/a>&nbsp;Cette fonction accepte du code SQL et renvoie du SQL format\u00e9. Consultez le WSDL ici. La partie importante, pr\u00e9sent\u00e9e ci-dessous, d\u00e9crit la m\u00e9thode beautifySql.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>  Am\u00e9liorer la pr\u00e9sentation du SQL <\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u00c9tape 1\u00a0: Cr\u00e9er la classe proxy<\/h4>\n\n\n\n<p>Ex\u00e9cution des op\u00e9rations suivantes\u2026<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:\\&gt;wsdl.exe https:\/\/www.gudusoft.com\/SQLFormatterWebService.wsdl<\/code><\/pre>\n\n\n\n<p>\u2026 g\u00e9n\u00e8re un fichier C#, SQLFormatterWebService.cs, contenant une classe nomm\u00e9e SQLFormatterWebService. Examinez la correspondance entre les m\u00e9thodes de cette classe et celles d\u00e9crites dans le fichier WSDL, notamment la m\u00e9thode suivante\u00a0:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>public string beautifySql(string dbvendor, string sql) dbvendor\u00a0: dialecte SQL de la base de donn\u00e9es actuellement prise en charge\u00a0: MSSQL, Oracle, MySQL et Access. sql\u00a0: code SQL \u00e0 formater.<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u00c9tape 2\u00a0: Compiler la classe proxy<\/h4>\n\n\n\n<p>Ensuite, vous devez compiler le fichier g\u00e9n\u00e9r\u00e9 automatiquement. Ce fichier ne contient aucun point d&#039;entr\u00e9e et doit donc \u00eatre compil\u00e9 comme une biblioth\u00e8que.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>C:&gt;csc \/t:library c:SQLFormatterWebService.cs<\/code><\/pre>\n\n\n\n<p>Cela cr\u00e9e un nouveau fichier, SQLFormatterWebService.dll.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u00c9tape 3\u00a0: Cr\u00e9er une application ASP.NET<\/h4>\n\n\n\n<p>Cette application, sqlformatter.aspx, utilise le service Web SQL Formatter.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;%@Assembly Name=&quot;SQLFormatterWebService&quot; %&gt;\r\n\r\n&lt;html&gt;\r\n   &lt;head&gt;\r\n      &lt;title&gt;D&eacute;monstration du service Web SQL Formatter &lt;\/title&gt;\r\n   &lt;\/head&gt;\r\n\r\n   &lt;body&gt;\r\n    &lt;form runat=&quot;server&quot; action=&quot;&quot;&gt;\r\n          &lt;asp:textbox id=&quot;inputsql&quot; text=&quot;select f1,f2 from t1&quot;\r\n                       textmode=&quot;MultiLine&quot; rows=&quot;10&quot; columns=&quot;60&quot;\r\n                       wrap=&quot;False&quot; runat=&quot;server&quot;\/&gt;\r\n   &lt;br&gt;&lt;asp:button text=&quot; Format Code &quot; onclick=&quot;onFormat&quot;\r\n                          runat=&quot;server&quot; \/&gt;\r\n          &lt;br&gt;&lt;asp:textbox id=&quot;outputsql&quot; textmode=&quot;MultiLine&quot;\r\n                           rows=&quot;10&quot; columns=&quot;60&quot; wrap=&quot;False&quot;\r\n                           runat=&quot;server&quot;\/&gt;\r\n\r\n   &lt;input type=&quot;hidden&quot; name=&quot;trp-form-language&quot; value=&quot;fr&quot;\/&gt;&lt;\/form&gt;\r\n   &lt;\/body&gt;\r\n&lt;\/html&gt;\r\n\r\n&lt;script language=&quot;c#&quot; runat=&quot;server&quot;&gt;\r\n   void onFormat (Object sender, EventArgs e)\r\n{\r\n      SQLFormatterWebService sqlformatter =\r\n         new SQLFormatterWebService();\r\n      outputsql.Text =\r\n         sqlformatter.beautifySql(&quot;mssql&quot;,inputsql.Text);\r\n}\r\n&lt;\/script&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u00c9tape 4\u00a0: Configurez cette application ASP.NET sur votre serveur IIS.<\/h4>\n\n\n\n<ul><li>4.1 Placez le fichier sqlformatter.aspx sous wwwroot, par exemple.<\/li><li>4.2 Placez le fichier SQLFormatterWebService.dll dans le r\u00e9pertoire bin sous wwwroot.<\/li><li>4.3 Ouvrez votre navigateur et saisissez http:\/\/localhost\/sqlformatter.aspx.<\/li><\/ul>\n\n\n\n<p>Profitez-en!<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Points d&#039;int\u00e9r\u00eat<\/h3>\n\n\n\n<p>Ce service web de formatage SQL peut \u00eatre largement utilis\u00e9, notamment sur les forums de sites web d\u00e9di\u00e9s aux bases de donn\u00e9es, o\u00f9 de nombreux extraits de code SQL sont soumis par les utilisateurs pour discussion. Il serait judicieux de formater ce code SQL avant sa publication sur le forum.<\/p>\n\n\n\n<p>Pour plus d&#039;informations, ces sites peuvent vous \u00eatre utiles si vous \u00eates int\u00e9ress\u00e9 par un formateur SQL\u00a0:<\/p>\n\n\n\n<ul><li>Service Web de formatage SQL<\/li><li><a href=\"http:\/\/www.wangz.net\/gsqlparser\/sqlpp\/sqlformat.htm\">Formateur SQL en ligne gratuit<\/a><\/li><li><a href=\"http:\/\/www.sqlparser.com\/\">Moteur d&#039;analyseur SQL utilis\u00e9 par le formateur SQL<\/a><\/li><\/ul>\n\n\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Updated Info (2022) This is an article written back in 2006 that was published on codeguru , and the technology used in this article may out of date. If you are looking for a good SQL formatter that can be used in your Java or Dotnet program, please check this page instead. If you are looking for a free while fantastic SQL query formatter, please check the Instant SQL formatter. Introduction SQL code is much easier and faster to read and understand when it is formatted, especially when it is a long and complicated SQL statement you are dealing with,\u2026<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":5}},"_links":{"self":[{"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/posts\/3471"}],"collection":[{"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/comments?post=3471"}],"version-history":[{"count":5,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/posts\/3471\/revisions"}],"predecessor-version":[{"id":6620,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/posts\/3471\/revisions\/6620"}],"wp:attachment":[{"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/media?parent=3471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/categories?post=3471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gudusoft.com\/fr\/wp-json\/wp\/v2\/tags?post=3471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}