cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
najruli
Frequent Visitor

How to delete REMOVE row in SQL table

Is is possible to delete single row in sql table from powerapps Icon. I am using gallery to add miltiple line item.

I am able to collect and Patch to SQL . I am able to remove from collection single row Remove(CollectionName, ThisItem) but not sure how to do similar thing for SQL any help will be appriciated.

Regards,

najruli

1 ACCEPTED SOLUTION

Accepted Solutions
najruli
Frequent Visitor

In fact, Instead removing rows directly from SQL Table, I created collect table which was easy add and delete Line Items after finishing my adds into collect then I added another Button where I saved all the Collect table to SQL Table.
Save Collect Table to SQL Table Code :

ForAll(CollectTable,
                                              Patch( SQL_Table, Defaults(SQL_Table),
                                                   {

                                         ID: ID,
                                         Name: Name,

                                         Address: Address,

                                        Email: Email

                                                   }

                                       )

);

Note: Collect Columns must match SQL Table Columns Names.

 

Regards,

View solution in original post

3 REPLIES 3
timl
Super User
Super User

Hi Najruli,

A simple way to remove a single row from a SQL Server table is to call the RemoveIf function and to provide a primary key value. As an example, here's how to remove a row from a customer table where CustomerID=8.

RemoveIf('[dbo].[Customer]', 
          CustomerID=8
)
v-xida-msft
Community Support
Community Support

Hi @najruli ,

Could you please share a bit more about your scenario?

Do you want to remove same record from your SQL Table when you remove single row from your Collection?

Further, do you collect the new items into a Collection, and then patch the Collection into your SQL Table?

 

If you want to remove one record from your SQL Table, you must find the record in your SQL Table firstly. I have made a test on my side, please take a try with the following workaround:

Add the following formula within the "Remove" icon within your Gallery:

Remove(
        '[dbo].[YourSQLTable]',
         LookUp('[dbo].[YourSQLTable]', PrimaryColumn = ThisItem.PrimaryColumn)   /* <-- Find the reocrd you want to update */
)

Note: The PrimaryColumn represents the Primary column in your SQL Table, which could identify one record uniquely.

 

More details about the LookUp function in PowerApps, please check the following article:

LookUp function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
najruli
Frequent Visitor

In fact, Instead removing rows directly from SQL Table, I created collect table which was easy add and delete Line Items after finishing my adds into collect then I added another Button where I saved all the Collect table to SQL Table.
Save Collect Table to SQL Table Code :

ForAll(CollectTable,
                                              Patch( SQL_Table, Defaults(SQL_Table),
                                                   {

                                         ID: ID,
                                         Name: Name,

                                         Address: Address,

                                        Email: Email

                                                   }

                                       )

);

Note: Collect Columns must match SQL Table Columns Names.

 

Regards,

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,239)