<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: SQL While do loops in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133387#M49827</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/69823"&gt;@elgeo&lt;/a&gt;&amp;nbsp;Here are two alternatives.&lt;/P&gt;&lt;P&gt;1. Use a recursive CTE&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WITH RECURSIVE loop_cte (lstart, lstring) AS (
  SELECT 5 AS lstart, '' AS lstring
  UNION ALL
  SELECT lstart - 1, CONCAT(lstring, 'VSTRING2')
  FROM loop_cte
  WHERE lstart &amp;gt; 1
)
SELECT * FROM loop_cte;&lt;/LI-CODE&gt;&lt;P&gt;2. you can use pyspark. If you are running the code in notebook.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lstart = 5
lstring = ""
vstring2 = "VSTRING2"

while lstart &amp;gt; 0:
    lstring += vstring2
    lstart -= 1
&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 30 Sep 2025 14:01:52 GMT</pubDate>
    <dc:creator>nayan_wylde</dc:creator>
    <dc:date>2025-09-30T14:01:52Z</dc:date>
    <item>
      <title>SQL While do loops</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/22051#M15069</link>
      <description>&lt;P&gt;Hello. Could you please suggest a workaround for a while do loop in Databricks SQL?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;WHILE LSTART&amp;gt;0 DO SET LSTRING=CONCAT(LSTRING, VSTRING2)&lt;/I&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Wed, 16 Nov 2022 10:45:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/22051#M15069</guid>
      <dc:creator>elgeo</dc:creator>
      <dc:date>2022-11-16T10:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: SQL While do loops</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133374#M49820</link>
      <description>&lt;P&gt;hi,&amp;nbsp;In Databricks SQL stored procedures (Unity Catalog, DBR ≥ 17.0), the WHILE ... DO loop is supported,&amp;nbsp;&lt;BR /&gt;equivalent code for this,&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;WHILE LSTART &amp;gt; 0 DO
    SET LSTRING = CONCAT(LSTRING, VSTRING2);
END WHILE;&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 12:10:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133374#M49820</guid>
      <dc:creator>ashishasr</dc:creator>
      <dc:date>2025-09-30T12:10:05Z</dc:date>
    </item>
    <item>
      <title>Re: SQL While do loops</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133380#M49824</link>
      <description>&lt;P&gt;Hi, yes it's possbile. Refer to below thread:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.databricks.com/t5/data-engineering/sql-stored-procedure-in-databricks/td-p/133371" target="_blank"&gt;SQL Stored Procedure in Databricks - Databricks Community - 133371&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Sep 2025 12:48:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133380#M49824</guid>
      <dc:creator>szymon_dybczak</dc:creator>
      <dc:date>2025-09-30T12:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: SQL While do loops</title>
      <link>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133387#M49827</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/69823"&gt;@elgeo&lt;/a&gt;&amp;nbsp;Here are two alternatives.&lt;/P&gt;&lt;P&gt;1. Use a recursive CTE&lt;/P&gt;&lt;LI-CODE lang="python"&gt;WITH RECURSIVE loop_cte (lstart, lstring) AS (
  SELECT 5 AS lstart, '' AS lstring
  UNION ALL
  SELECT lstart - 1, CONCAT(lstring, 'VSTRING2')
  FROM loop_cte
  WHERE lstart &amp;gt; 1
)
SELECT * FROM loop_cte;&lt;/LI-CODE&gt;&lt;P&gt;2. you can use pyspark. If you are running the code in notebook.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;lstart = 5
lstring = ""
vstring2 = "VSTRING2"

while lstart &amp;gt; 0:
    lstring += vstring2
    lstart -= 1
&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 30 Sep 2025 14:01:52 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/sql-while-do-loops/m-p/133387#M49827</guid>
      <dc:creator>nayan_wylde</dc:creator>
      <dc:date>2025-09-30T14:01:52Z</dc:date>
    </item>
  </channel>
</rss>

