<?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: What's the equivalent of &amp;quot;DECLARE...&amp;quot; in Databricks SQL ? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31888#M23240</link>
    <description>&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 08:47:40 GMT</pubDate>
    <dc:creator>wyzer</dc:creator>
    <dc:date>2022-02-14T08:47:40Z</dc:date>
    <item>
      <title>What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31878#M23230</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm new in Databricks SQL, and I'm comming from SQL Server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to know what's the equivalent of :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;DECLARE @P_Name varchar(50) = 'BackOffice'&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's for use it like this : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;CREATE DATABASE @P_Name&lt;/B&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 14:50:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31878#M23230</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-01-11T14:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31879#M23231</link>
      <description>&lt;P&gt;Hi there, @Salah K.​! Welcome to the community and thanks for your question. Let's give the community more time to answer your question. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 00:52:33 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31879#M23231</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-01-12T00:52:33Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31880#M23232</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Ok, thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 09:26:37 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31880#M23232</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-01-12T09:26:37Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31881#M23233</link>
      <description>&lt;P&gt;@Salah K.​&amp;nbsp; Databricks SQL does not support T-SQL style variable declarations. However,  Databricks SQL _does_ support variables in a different way.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this: "&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATABASE {{ database_name }}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will see a "widget" where you can pass in the database name&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 12:49:07 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31881#M23233</guid>
      <dc:creator>BilalAslamDbrx</dc:creator>
      <dc:date>2022-01-12T12:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31882#M23234</link>
      <description>&lt;P&gt;Thank you for your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How can I use it like this please : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATABASE CONCAT({{ database_name }}, 'BackOIffice')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because it doesn't work.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 13:31:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31882#M23234</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-01-12T13:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31883#M23235</link>
      <description>&lt;P&gt;@Salah K.​&amp;nbsp; that won't work because these variables are evaluated outside of SQL.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 13:36:31 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31883#M23235</guid>
      <dc:creator>BilalAslamDbrx</dc:creator>
      <dc:date>2022-01-12T13:36:31Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31884#M23236</link>
      <description>&lt;P&gt;Ok.&lt;/P&gt;&lt;P&gt;So in Databricks SQL when can't create Stored Procedure for example ?&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 13:52:47 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31884#M23236</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-01-12T13:52:47Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31885#M23237</link>
      <description>&lt;P&gt;No, we do support UDFs (our name for sprocs). For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CREATE OR REPLACE FUNCTION generate_db_name(name STRING COMMENT 'Database name')
  RETURNS STRING
  COMMENT 'Creates a database name postfixed by BackOffice'
  CONTAINS SQL DETERMINISTIC
  RETURN name || 'BackOffice'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;However, this fails as it appears CREATE DATABASE only accepts a string literal.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;create database generate_db_name('Testing');&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 14:06:05 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31885#M23237</guid>
      <dc:creator>BilalAslamDbrx</dc:creator>
      <dc:date>2022-01-12T14:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31886#M23238</link>
      <description>&lt;P&gt;Ok, thank you very for your time.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jan 2022 14:20:20 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31886#M23238</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-01-12T14:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31887#M23239</link>
      <description>&lt;P&gt;Use python and build up a sql string which can be executed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;e,g&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a = 'backoffice'&lt;/P&gt;&lt;P&gt;sql = f'select * from {a}'&lt;/P&gt;&lt;P&gt;print(sql)&lt;/P&gt;&lt;P&gt;spark.sql(sql)&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jan 2022 10:04:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31887#M23239</guid>
      <dc:creator>Bilal1</dc:creator>
      <dc:date>2022-01-19T10:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31888#M23240</link>
      <description>&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 08:47:40 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31888#M23240</guid>
      <dc:creator>wyzer</dc:creator>
      <dc:date>2022-02-14T08:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31889#M23241</link>
      <description>&lt;P&gt;Hello, &lt;/P&gt;&lt;P&gt;Maybe you are looking that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;%sql&lt;/P&gt;&lt;P&gt;CREATE WIDGET TEXT P_Name DEFAULT 'BackOffice';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CREATE DATABASE&amp;nbsp;getArgument("P_Name ")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.databricks.com/notebooks/widgets.html#widgets-in-sql" target="test_blank"&gt;https://docs.databricks.com/notebooks/widgets.html#widgets-in-sql&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 18:00:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31889#M23241</guid>
      <dc:creator>sauri</dc:creator>
      <dc:date>2022-05-31T18:00:13Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31890#M23242</link>
      <description>&lt;P&gt;Please note that SQL Variables are supported in pure SQL. Here is an example notebook. &lt;A href="https://github.com/rchynoweth/DemoContent/blob/main/Misc/SQL_Variables.sql" target="test_blank"&gt;https://github.com/rchynoweth/DemoContent/blob/main/Misc/SQL_Variables.sql&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The syntax would be something like the following: &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SET var.database_name = my_database ; 
&amp;nbsp;
SELECT * FROM ${var.database_name}.my_table; 
&amp;nbsp;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Note that the "var" can be any string i.e. it can be c.var_name instead. &lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 17:54:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31890#M23242</guid>
      <dc:creator>Ryan_Chynoweth</dc:creator>
      <dc:date>2022-10-03T17:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31891#M23243</link>
      <description>&lt;P&gt;Awesome addition, thanks @Ryan Chynoweth​&amp;nbsp;! &lt;/P&gt;</description>
      <pubDate>Mon, 03 Oct 2022 22:05:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31891#M23243</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-10-03T22:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31892#M23244</link>
      <description>&lt;P&gt;This should be the accepted answer!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 01:31:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31892#M23244</guid>
      <dc:creator>verargulla</dc:creator>
      <dc:date>2023-03-23T01:31:48Z</dc:date>
    </item>
    <item>
      <title>Re: What's the equivalent of "DECLARE..." in Databricks SQL ?</title>
      <link>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31893#M23245</link>
      <description>&lt;P&gt;Hi @Salah K.​&amp;nbsp;&lt;/P&gt;&lt;P&gt;you can go through this code block&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%python &lt;/P&gt;&lt;P&gt;P_Name = 'BackOffice'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;spark.sql(f""" create database  {P_name} """)&lt;/P&gt;</description>
      <pubDate>Thu, 23 Mar 2023 07:04:26 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/what-s-the-equivalent-of-quot-declare-quot-in-databricks-sql/m-p/31893#M23245</guid>
      <dc:creator>Amit_352107</dc:creator>
      <dc:date>2023-03-23T07:04:26Z</dc:date>
    </item>
  </channel>
</rss>

