{"id":4648,"date":"2025-04-15T09:59:12","date_gmt":"2025-04-15T16:59:12","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/semantic-kernel\/?p=4648"},"modified":"2025-04-23T09:52:02","modified_gmt":"2025-04-23T16:52:02","slug":"guest-blog-bridging-business-and-technology-transforming-natural-language-queries-into-sql-with-semantic-kernel-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/agent-framework\/guest-blog-bridging-business-and-technology-transforming-natural-language-queries-into-sql-with-semantic-kernel-part-2\/","title":{"rendered":"Guest Blog: Bridging Business and Technology: Transforming Natural Language Queries into SQL with Semantic Kernel Part 2"},"content":{"rendered":"<p>Today we&#8217;d like to welcome back a team of internal Microsoft employees for part 2 of their guest blog series focused on Bridging Business and Technology: Transforming Natural Language Queries into SQL with Semantic Kernel. We&#8217;ll turn it over to our authors &#8211; Samer El Housseini, Riccardo Chiodaroli, Daniel Labbe, Fabrizio Ruocco and Angel Sevillano Cabrera to dive in.<\/p>\n<h2 id=\"introduction\">Introduction<\/h2>\n<p>In today&#8217;s data-driven business landscape, access to information is critical for decision-making. However, a persistent challenge has been the technical barrier between business users who need data insights and the complex database systems that house this information. The solution? Natural Language to SQL (NL2SQL) technology &#8211; a transformative approach that allows users to query databases using everyday language rather than complex SQL syntax.<\/p>\n<p>In this article, we&#8217;ll explore how Microsoft&#8217;s Semantic Kernel framework provides a powerful foundation for building an innovative NL2SQL system. We&#8217;ll examine both the business value this brings to organizations and the technical implementation details that make it possible.<\/p>\n<h2 id=\"part-1-the-business-case-for-natural-language-to-sql\">Part 1: The Business Case for Natural Language to SQL<\/h2>\n<h3 id=\"breaking-down-technical-barriers\">Breaking Down Technical Barriers<\/h3>\n<p>Consider this common scenario: A business analyst needs to understand &#8220;What is the average wellness index for patients with chronic conditions?&#8221; Traditionally, this would require either:<\/p>\n<ol>\n<li>Learning SQL and database structure<\/li>\n<li>Submitting a request to the IT department and waiting<\/li>\n<li>Using limited pre-built reporting tools<\/li>\n<\/ol>\n<p>None of these options is ideal. The first requires significant time investment, the second creates bottlenecks, and the third lacks flexibility. NL2SQL eliminates these barriers by allowing business users to simply ask questions in plain English.<\/p>\n<h3 id=\"measurable-business-impact\">Measurable Business Impact<\/h3>\n<p>The NL2SQL approach delivers several quantifiable benefits:<\/p>\n<ol>\n<li><strong>Accelerated Decision-Making<\/strong>: By removing the technical intermediary, insights can be obtained in minutes rather than days.<\/li>\n<li><strong>Resource Optimization<\/strong>: IT teams can focus on higher-value activities rather than servicing routine data requests.<\/li>\n<li><strong>Democratized Data Access<\/strong>: More employees can leverage data, creating a more informed organization.<\/li>\n<li><strong>Improved Data Governance<\/strong>: Business rules are systematically enforced in the system at query time, ensuring consistently compliant queries.<\/li>\n<\/ol>\n<h3 id=\"real-world-applications\">Real-World Applications<\/h3>\n<p>Healthcare organizations can use this technology to quickly analyze patient outcomes, insurance providers can assess coverage patterns, and pharmaceutical companies can evaluate medication adherence &#8211; all without specialized database knowledge. The application is particularly powerful in regulated industries where both speed and compliance are essential. These examples can be extended to any industry for any database-related use case.<\/p>\n<h2 id=\"part-2-the-technical-architecture-building-a-state-machine-for-nl2sql-with-semantic-kernel\">Part 2: The Technical Architecture: Building a State Machine for NL2SQL with Semantic Kernel<\/h2>\n<p>Now, let&#8217;s dive into the technical implementation of this powerful system. The architecture leverages Microsoft&#8217;s Semantic Kernel Process Framework to create a sophisticated state machine that handles the complex task of translating natural language to SQL.<\/p>\n<h3 id=\"the-semantic-kernel-process-framework\">The Semantic Kernel Process Framework<\/h3>\n<p>Semantic Kernel provides a structured way to build AI-powered applications with a process-oriented approach. This project leverages Semantic Kernel&#8217;s Process builder to create a state machine where:<\/p>\n<ol>\n<li>Each step in the NL2SQL conversion is a distinct process step<\/li>\n<li>Events trigger transitions between steps<\/li>\n<li>The entire workflow manages state and handles failures gracefully<\/li>\n<\/ol>\n<p>The result is a robust system that can iteratively refine queries until they meet both syntactic and semantic requirements. Dive into the repo here: <span data-teams=\"true\"><a id=\"menur1hgr\" class=\"fui-Link ___1q1shib f2hkw1w f3rmtva f1ewtqcl fyind8e f1k6fduh f1w7gpdv fk6fouc fjoy568 figsok6 f1s184ao f1mk8lai fnbmjn9 f1o700av f13mvf36 f1cmlufx f9n3di6 f1ids18y f1tx3yz7 f1deo86v f1eh06m1 f1iescvh fhgqx19 f1olyrje f1p93eir f1nev41a f1h8hb77 f1lqvz6u f10aw75t fsle3fq f17ae5zn\" title=\"https:\/\/github.com\/azure-samples\/semantic-kernel-advanced-usage\/tree\/main\/templates\/natural_language_to_sql\" href=\"https:\/\/github.com\/Azure-Samples\/semantic-kernel-advanced-usage\/tree\/main\/templates\/natural_language_to_SQL\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Link semantic-kernel-advanced-usage\/templates\/natural_language_to_SQL at main \u00b7 Azure-Samples\/semantic-kernel-advanced-usage\">semantic-kernel-advanced-usage\/templates\/natural_language_to_SQL at main \u00b7 Azure-Samples\/semantic-kernel-advanced-usage<\/a>.<\/span><\/p>\n<h3 id=\"innovative-multi-stage-processing\">Innovative Multi-Stage Processing<\/h3>\n<p>What makes this NL2SQL implementation particularly innovative is its multi-stage approach:<\/p>\n<ol>\n<li><strong>Table Identification<\/strong>: First determining which database tables are relevant to the query<\/li>\n<li><strong>Column Extraction<\/strong>: Then identifying specific columns needed from those tables identifid in the previous step<\/li>\n<li><strong>SQL Generation<\/strong>: Creating the initial SQL statement<\/li>\n<li><strong>Syntactic Validation<\/strong>: Verifying SQL correctness<\/li>\n<li><strong>Business Rule Validation<\/strong>: Ensuring compliance with business semantics<\/li>\n<li><strong>Execution<\/strong>: Running the validated query<\/li>\n<\/ol>\n<p>This approach solves a key challenge in NL2SQL systems &#8211; balancing the need to understand what data is available (tables\/columns) with how to properly query it (syntax\/semantics).<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11.png\"><img decoding=\"async\" class=\"alignnone wp-image-4695 size-full\" src=\"https:\/\/devblogs.microsoft.com\/semantic-kernel\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11.png\" alt=\"Image image 11\" width=\"1536\" height=\"514\" srcset=\"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11.png 1536w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11-300x100.png 300w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11-1024x343.png 1024w, https:\/\/devblogs.microsoft.com\/agent-framework\/wp-content\/uploads\/sites\/78\/2025\/04\/image-11-768x257.png 768w\" sizes=\"(max-width: 1536px) 100vw, 1536px\" \/><\/a><\/p>\n<h3 id=\"the-state-machine-implementation\">The State Machine Implementation<\/h3>\n<p>Let&#8217;s examine the core components of the implementation:<\/p>\n<pre><code class=\"python\">def get_sql_process(self) -&gt; KernelProcess:\r\n    \"\"\"Build and configure the SQL generation process with all steps and their transitions.\"\"\"\r\n    process = ProcessBuilder(name=\"SQLGenerationProcess\")\r\n\r\n    # Add steps to the process\r\n    table_step = process.add_step(TableNameStep)\r\n    column_step = process.add_step(ColumnNameStep)\r\n    sql_generation_step = process.add_step(SQLGenerationStep)\r\n    business_rules_step = process.add_step(BusinessRulesStep)\r\n    validation_step = process.add_step(ValidationStep)\r\n    execution_step = process.add_step(ExecutionStep)\r\n\r\n    # Define the process flow\r\n    process.on_input_event(event_id=SQLEvents.StartProcess).send_event_to(target=table_step, parameter_name=\"data\")\r\n    \r\n    table_step.on_event(event_id=SQLEvents.TableNameStepDone).send_event_to(\r\n        target=column_step, parameter_name=\"data\"\r\n    )\r\n    \r\n    column_step.on_event(event_id=SQLEvents.ColumnNameStepDone).send_event_to(\r\n        target=sql_generation_step, parameter_name=\"data\"\r\n    )\r\n    \r\n    # ...additional event flow definitions...\r\n\r\n    return process.build()\r\n<\/code><\/pre>\n<p>This elegant process definition creates a workflow where:<\/p>\n<ol>\n<li>The process starts by identifying tables<\/li>\n<li>On successful table identification, it moves to column identification<\/li>\n<li>With tables and columns identified, it generates SQL<\/li>\n<li>The SQL undergoes business rule validation<\/li>\n<li>Then syntax validation<\/li>\n<li>Finally, execution if all validations pass<\/li>\n<\/ol>\n<p>Most importantly, the system includes feedback loops. If validation fails at any stage, the process can return to an earlier step with information about what went wrong, enabling iterative refinement.<\/p>\n<h3 id=\"prompting-excellence-the-secret-to-effective-nl2sql\">Prompting Excellence: The Secret to Effective NL2SQL<\/h3>\n<p>At the heart of this system are carefully designed prompts that guide the language model through each step. Through iterative and repeated refinements, these prompts have been drafted and were evolved to make sure that the system\u00a0<strong>converges<\/strong>\u00a0on a solution to generate a proper SQL statement. Let&#8217;s examine one of these prompts:<\/p>\n<pre><code class=\"python\">get_table_names_prompt_template = \"\"\"\r\n## Instructions:\r\nYou are an advanced SQL query generator. Your task is to extract the relevant table names using the following **natural language question** from a list of business tables. \r\n\r\nYou **MUST** take a conservative approach: if in doubt whether a table is relevant or not, then you need to include it in the list. It is better to have it and not need it than to need it and not have it. Make sure to review the Business Rules when deciding on the table names.\r\n\r\nMake sure to include all foreign keys and relationships that are relevant to the user's question that are necessary to join the tables. If the tables do not have direct relationships, please analyze the situation and include any intermediary tables that can join the tables, and might be necessary to answer the user's question.\r\n\r\n## **Business Rules**\r\n{rules}\r\n\r\n## User Query\r\n{user_query}\r\n\r\n## START OF LIST OF TABLES\r\n{table_list}\r\n## END OF LIST OF TABLES\r\n\r\n# **Inputs from previous generation rounds**\r\n...\r\n\"\"\"\r\n<\/code><\/pre>\n<p>This prompt is structured to: 1. Precisely define the task (extract table names) 2. Provide context (business rules, available tables) 3. Include previous generation attempts for refinement 4. Specify the expected output format<\/p>\n<p>Similar specialized prompts exist for each step in the process, ensuring the language model understands exactly what&#8217;s needed at each stage.<\/p>\n<h3 id=\"handling-errors-and-refining-results\">Handling Errors and Refining Results<\/h3>\n<p>A particularly powerful aspect of this system is its ability to learn from failures through the state machine&#8217;s feedback loops:<\/p>\n<pre><code class=\"python\">business_rules_step.on_event(event_id=SQLEvents.BusinessRulesFailed).send_event_to(\r\n    target=sql_generation_step, parameter_name=\"data\"\r\n)\r\n\r\nvalidation_step.on_event(event_id=SQLEvents.ValidationFailed).send_event_to(\r\n    target=sql_generation_step, parameter_name=\"data\"\r\n)\r\n\r\nexecution_step.on_event(event_id=SQLEvents.ExecutionError).send_event_to(\r\n    target=table_step, parameter_name=\"data\"\r\n)\r\n<\/code><\/pre>\n<p>When a validation or execution fails, the system captures error details and feeds them back into earlier steps. This creates an iterative refinement process that can solve complex queries that might fail on the first attempt.<\/p>\n<p>For example, if business rule validation fails, the system doesn&#8217;t simply report an error &#8211; it returns to SQL generation with notes about what rules were violated, allowing for targeted improvements.<\/p>\n<h2 id=\"part-3-data-structures---the-foundation-of-intelligent-sql-generation\">Part 3: Data Structures &#8211; The Foundation of Intelligent SQL Generation<\/h2>\n<p>At the core of this NL2SQL system are several carefully designed data structures that power the various stages of query processing. These structures provide the essential context needed for the system to understand database schema, enforce business rules, and produce accurate SQL queries.<\/p>\n<h3 id=\"table-descriptions-the-first-layer-of-understanding\">Table Descriptions: The First Layer of Understanding<\/h3>\n<p>The system begins its process with a comprehensive set of table descriptions that provide high-level information about each database entity. This structure is critical for the initial table identification step, allowing the system to determine which tables might be relevant to a user&#8217;s query.<\/p>\n<p>Each table description includes: &#8211; The table name (e.g., &#8220;HC_Patient_Daily_Summary_v3&#8221;) &#8211; A detailed narrative description of the table&#8217;s purpose and contents &#8211; Information about relationships with other tables through foreign keys<\/p>\n<p>For example, when a user asks about &#8220;medication adherence for patients with chronic conditions,&#8221; the system can quickly identify that both the medication summary and patient summary tables are likely relevant based on these descriptions.<\/p>\n<h3 id=\"database-schema-model-detailed-column-level-knowledge\">Database Schema Model: Detailed Column-Level Knowledge<\/h3>\n<p>Once relevant tables are identified, the system leverages a more detailed schema model that includes comprehensive information about each column within those tables. This model provides:<\/p>\n<ul>\n<li>Column names and data types<\/li>\n<li>Detailed descriptions of what each column represents<\/li>\n<li>Valid value ranges or enumerations<\/li>\n<li>Foreign key relationships between tables<\/li>\n<\/ul>\n<p>This rich column-level information enables the system to select appropriate columns for the query, understand data types for proper syntax, and establish necessary joins between related tables. It&#8217;s particularly valuable during the column identification step and subsequent SQL generation.<\/p>\n<h3 id=\"business-rules-semantic-intelligence-layer\">Business Rules: Semantic Intelligence Layer<\/h3>\n<p>Perhaps the most distinctive aspect of this NL2SQL system is its integration of business rules that add a semantic intelligence layer to query generation. These rules are structured as conditions and actions, with each rule having:<\/p>\n<ul>\n<li>A unique identifier (e.g., &#8220;HC1&#8221;)<\/li>\n<li>A name (e.g., &#8220;Chronic Condition Filtering&#8221;)<\/li>\n<li>A condition that triggers the rule<\/li>\n<li>An action to take when the condition is met<\/li>\n<\/ul>\n<p>For example, when a query mentions high-risk patients, the system knows to apply specific filtering criteria. This is\u00a0<strong>codified business knowledge<\/strong>\u00a0that only the organization can collect and compile to serve as Business Rules for the SQL generation process.<\/p>\n<p>These rules ensure that generated queries adhere to the business&#8217;s understanding of data semantics. The business rules are evaluated during the dedicated Business Rules step in the process, providing a critical validation layer before execution.<\/p>\n<h3 id=\"the-power-of-integrated-data-structures\">The Power of Integrated Data Structures<\/h3>\n<p>What makes this approach particularly effective is how these data structures work together through the state machine:<\/p>\n<ol>\n<li><strong>Table Descriptions<\/strong>\u00a0enable quick, high-level identification of relevant tables<\/li>\n<li><strong>Database Schema Model<\/strong>\u00a0provides the detailed column information needed for precise query construction<\/li>\n<li><strong>Business Rules<\/strong>\u00a0ensure semantic correctness beyond just syntactic validity<\/li>\n<\/ol>\n<p>Through this layered approach to data modeling, the system can progressively refine its understanding of what the user is asking for and how to represent it correctly in SQL. The feedback loops in the state machine allow the system to revisit these data structures as needed when validation issues arise, creating a robust and self-correcting query generation system.<\/p>\n<p>This architecture demonstrates how comprehensive data modeling combined with a process-oriented approach can create an AI system that bridges the gap between natural language questions and technically correct, semantically appropriate database queries.<\/p>\n<h2 id=\"part-4-example-run\">Part 4: Example Run<\/h2>\n<p>In the repo, we have provided a testing SQLite database that comes with complete synthetic generated data. The database implements a comprehensive healthcare monitoring system that tracks patient health data through connected medical devices. It integrates daily patient summaries with detailed information about medications, devices, insurance plans, and providers to support remote patient monitoring, medication adherence tracking, and healthcare accessibility analysis.<\/p>\n<p>You can note that the below generated SQL statement has a SQLite\u00a0<em>dialect<\/em>. This is by design, for this demo scenario. The SQL dialect can easily be changed in the prompts to adapt to whatever database this solution is connected to.<\/p>\n<p>Using our solution, we have asked it the following question:\u00a0<code>\"Find the medication adherence level distribution for elderly patients (age 65+)\"<\/code>.<\/p>\n<p>Checking the successful execution run using OpenAI&#8217;s\u00a0<code>o3-mini<\/code>\u00a0model, the flow went from\u00a0<strong>StartProcess<\/strong>\u00a0\u2192\u00a0<strong>TableNameStep<\/strong>\u00a0\u2192\u00a0<strong>ColumnNameStep<\/strong>\u00a0\u2192\u00a0<strong>SQLGenerationStep<\/strong>\u00a0\u2192\u00a0<strong>BusinessRulesStep<\/strong>\u00a0\u2192\u00a0<strong>ValidationStep<\/strong>\u00a0\u2192\u00a0<strong>ExecutionStep<\/strong>\u00a0\u2192\u00a0<strong>ExecutionSuccess<\/strong>\u00a0\u2192\u00a0<strong>Process End<\/strong>, without any loops or errors. The query was not overly complex, and required only one JOIN between 2 tables.<\/p>\n<p>Below are the reformatted logs for better readability:<\/p>\n<pre><code class=\"python\">    StartProcess: User Query\r\n    -&gt; \"Find the medication adherence level distribution for elderly patients (age 65+)\"\r\n\r\n    &gt;&gt; Running TableNameStep...\r\n        Extracted table names:\r\n            - HC_Patient_Daily_Summary_v3\r\n            - HC_Patient_Medication_Summary_v3\r\n        Emitted event: TableNameStepDone.\r\n\r\n    &gt;&gt; Running ColumnNameStep...\r\n        Extracted column names for HC_Patient_Medication_Summary_v3:\r\n            - ADHERENCE_LEVEL, PATIENT_ID, PROVIDER_ID, MEDICATION_ID, RECORD_DATE, PRESCRIPTION_ID\r\n        Extracted column names for HC_Patient_Daily_Summary_v3:\r\n            - PATIENT_ID, INSURANCE_REC.PATIENT_AGE_GROUP_CD, RECORD_DATE\r\n        Emitted event: ColumnNameStepDone.\r\n\r\n    &gt;&gt; Running SQLGenerationStep...\r\n        Generated SQL statement:\r\n            SELECT\r\n            HC_Patient_Medication_Summary_v3.ADHERENCE_LEVEL,\r\n            COUNT(DISTINCT HC_Patient_Medication_Summary_v3.PATIENT_ID) AS PATIENT_COUNT\r\n            FROM HC_Patient_Medication_Summary_v3\r\n            JOIN HC_Patient_Daily_Summary_v3\r\n            ON HC_Patient_Medication_Summary_v3.PATIENT_ID = HC_Patient_Daily_Summary_v3.PATIENT_ID\r\n            WHERE HC_Patient_Daily_Summary_v3.\"INSURANCE_REC.PATIENT_AGE_GROUP_CD\" = '65+'\r\n            GROUP BY HC_Patient_Medication_Summary_v3.ADHERENCE_LEVEL\r\n        Emitted event: SQLGenerationStepDone.\r\n\r\n    &gt;&gt; Running BusinessRulesStep...\r\n        All business rules validated: OK\r\n        Emitted event: BusinessRulesStepDone.\r\n\r\n    &gt;&gt; Running ValidationStep...\r\n        SQL syntax and structure validated: OK\r\n        Emitted event: ValidationPassed.\r\n\r\n    &gt;&gt; Running ExecutionStep...\r\n        Executing SQL...\r\n        Results:\r\n            - High:   588\r\n            - Medium: 723\r\n            - Low:    16\r\n        Emitted event: ExecutionSuccess.\r\n\r\n    Process completed!\r\n\r\n    &gt;&gt; Final Answer:\r\n        Among elderly patients (age 65+), there are:\r\n            - 588 patients with High adherence\r\n            - 723 patients with Medium adherence\r\n            - 16 patients with Low adherence\r\n<\/code><\/pre>\n<h2 id=\"part-5-performance-considerations-and-future-improvements\">Part 5: Performance Considerations and Future Improvements<\/h2>\n<p>While the state machine approach for NL2SQL represents a significant advancement over traditional techniques, it&#8217;s important to acknowledge its current performance characteristics and areas for improvement.<\/p>\n<h3 id=\"current-performance-profile\">Current Performance Profile<\/h3>\n<p>The performance of this innovative approach varies considerably based on database complexity:<\/p>\n<ul>\n<li><strong>Simple Databases<\/strong>: For schemas with 5-10 tables with straightforward relationships and minimal business rules, the system achieves impressive accuracy (~90%), especially when leveraging more efficient models like O3-mini rather than GPT-4o. These simpler contexts allow the state machine to quickly converge on correct solutions with fewer iterations.<\/li>\n<li><strong>Complex Databases<\/strong>: For enterprise-level databases with tens to hundreds of tables, hundreds of columns per table, and complex business rules, performance drops significantly. The multi-step process may require more iterations through feedback loops, and the increased context complexity challenges even advanced language models.<\/li>\n<\/ul>\n<h3 id=\"comparative-advantage\">Comparative Advantage<\/h3>\n<p>Despite these limitations, extensive experimentation has demonstrated that this process-oriented approach consistently outperforms one-shot approaches using &#8220;mega prompts&#8221; that attempt to solve the entire problem at once. The advantages include:<\/p>\n<ol>\n<li><strong>Focused Context<\/strong>: Each step works with only the most relevant subset of information rather than overwhelming the model with the entire database schema and all business rules.<\/li>\n<li><strong>Error Recovery<\/strong>: The feedback loops allow the system to learn from mistakes and iteratively improve, rather than failing completely on the first error.<\/li>\n<li><strong>Transparent Debugging<\/strong>: The state machine approach makes it easier to identify exactly where in the process errors occur, facilitating targeted improvements.<\/li>\n<\/ol>\n<h3 id=\"future-improvement-paths\">Future Improvement Paths<\/h3>\n<p>Several promising avenues for improving system performance including implementing more sophisticated schema representation techniques could improve the system&#8217;s ability to understand complex database structures: &#8211; Graph-based schema representations that better capture entity relationships &#8211; Pre-computed embeddings of table and column descriptions for faster semantic matching (Azure AI Search + RAG) &#8211; Hierarchical schema representations that group related entities<\/p>\n<h3 id=\"conclusion-on-performance\">Conclusion on Performance<\/h3>\n<p>The state machine approach represents a valuable architectural pattern for tackling the complexity of NL2SQL systems. While current performance has room for improvement, especially with complex databases, the fundamental pattern of breaking down the problem, enabling feedback loops, and progressively refining solutions provides a solid foundation for future advancements.<\/p>\n<p>As language models continue to evolve in capability and efficiency, this architecture is well-positioned to take advantage of those improvements while maintaining its core strengths in managing complexity and providing transparent, iterative refinement.<\/p>\n<h2 id=\"conclusion-the-future-of-data-interaction\">Conclusion: The Future of Data Interaction<\/h2>\n<p>The NL2SQL system built with Semantic Kernel represents a significant advancement in how businesses can interact with their data. By bridging the gap between natural language and database queries, it empowers non-technical users to harness the full power of their organization&#8217;s data assets.<\/p>\n<p>What makes this implementation particularly effective is the combination of:<\/p>\n<ol>\n<li><strong>Incremental processing<\/strong>: Breaking the complex task into manageable steps<\/li>\n<li><strong>Iterative refinement<\/strong>: Using feedback loops to improve results<\/li>\n<li><strong>Semantic understanding<\/strong>: Applying both syntactic and business rule validation<\/li>\n<li><strong>Structured workflow<\/strong>: Leveraging Semantic Kernel&#8217;s process framework<\/li>\n<li><strong>Smart Data Structures<\/strong>: Using smart data structures that feed language models the right information at the right time withing their context window limits<\/li>\n<\/ol>\n<p>As language models continue to advance, this type of system will become increasingly powerful, potentially eliminating the need for SQL knowledge entirely in many business contexts.<\/p>\n<p>For organizations looking to democratize data access while maintaining governance controls, an NL2SQL system built on Semantic Kernel provides an elegant solution that balances accessibility with compliance &#8211; bringing us one step closer to truly conversational interaction with databases.<\/p>\n<h3 id=\"wan-to-learn-more\">Wan to Learn More?<\/h3>\n<ul>\n<li>Semantic Kernel Advanced Usage Repo:\u00a0<a href=\"https:\/\/github.com\/Azure-Samples\/semantic-kernel-advanced-usage\" target=\"_blank\" rel=\"nofollow noopener\">Link<\/a><\/li>\n<li>Implementation Details of the NL2SQL Use Case:\u00a0<a href=\"https:\/\/github.com\/Azure-Samples\/semantic-kernel-advanced-usage\/tree\/main\/templates\/natural_language_to_SQL\" target=\"_blank\" rel=\"nofollow noopener\">Link<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Today we&#8217;d like to welcome back a team of internal Microsoft employees for part 2 of their guest blog series focused on Bridging Business and Technology: Transforming Natural Language Queries into SQL with Semantic Kernel. We&#8217;ll turn it over to our authors &#8211; Samer El Housseini, Riccardo Chiodaroli, Daniel Labbe, Fabrizio Ruocco and Angel Sevillano [&hellip;]<\/p>\n","protected":false},"author":149071,"featured_media":2302,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[117,1],"tags":[48,63,9],"class_list":["post-4648","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guest-blog","category-semantic-kernel","tag-ai","tag-microsoft-semantic-kernel","tag-semantic-kernel"],"acf":[],"blog_post_summary":"<p>Today we&#8217;d like to welcome back a team of internal Microsoft employees for part 2 of their guest blog series focused on Bridging Business and Technology: Transforming Natural Language Queries into SQL with Semantic Kernel. We&#8217;ll turn it over to our authors &#8211; Samer El Housseini, Riccardo Chiodaroli, Daniel Labbe, Fabrizio Ruocco and Angel Sevillano [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4648","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/users\/149071"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/comments?post=4648"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/posts\/4648\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media\/2302"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/media?parent=4648"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/categories?post=4648"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/agent-framework\/wp-json\/wp\/v2\/tags?post=4648"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}