cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
najruli
Level: Powered On

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
Level: Powered On

Re: How to delete REMOVE row in SQL table

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
Super User
Super User

Re: How to delete REMOVE row in SQL table

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
)
Community Support Team
Community Support Team

Re: How to delete REMOVE row in SQL table

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
Level: Powered On

Re: How to delete REMOVE row in SQL table

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

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 88 members 4,269 guests
Please welcome our newest community members: