Hi @Glasier
Welcome to the Microsoft Q&A and thank you for posting your questions here.
As per this Documentation, It is only mentioned about the usage of the existing Widgets in the SQL warehouse but not the creation of the widgets through SQL code.
You can see that it is giving the same result for the removal of widget as well.
It seems to be currently, creation and removal of widgets through SQL code is not supported in SQL warehouse.
Appreciate if you could share the feedback on our feedback channel. Which would be open for the user community to upvote & comment on. This allows our product teams to effectively prioritize your request against our existing feature backlog and gives insight into the potential impact of implementing the suggested feature.
If you want to use widgets, you can create the and remove the widgets by using the notebook UI. Go to Edit-> Add widget -> create widget like below.
After creating widget, you can access the widget value in the SQL warehouse notebook by using :<widget_name>
like below.
As an alternative, you could create a table to keep track of the widgets you need. This table can have a column for each widget. You can update or remove rows as needed and use the row value to access the widget's value.
Hope this helps. Do let us know if you any further queries.
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.