Is it possible to update only specific fields in SQL server Database?

Posts   
 
    
Posts: 72
Joined: 11-Aug-2006
# Posted on: 07-May-2023 11:53:54   

Hello

I have a product table in SQL server that has some fields that are large and don't change often - is it possible to use the code to update only some fields in the database, only the modified fields for example?

thanks Martin

Posts: 72
Joined: 11-Aug-2006
# Posted on: 07-May-2023 22:26:53   

Is it possible to use "updatable views"? In SQL Server management studio you can have a view that only contains a subset of the fields needed.

A use case for this would be where you have
- a product list with approx. 10 fields ( just a subset of all fields ) and update what you need - the full product if you are editing a single product that contains large fields that contain HTML / descriptive text that you don't need to load / update with every change of some fields with the list.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 08-May-2023 10:46:09   

martytheman wrote:

Hello

I have a product table in SQL server that has some fields that are large and don't change often - is it possible to use the code to update only some fields in the database, only the modified fields for example?

thanks Martin

If you fetch an entity, and change only e.g. 2 fields, then an UPDATE query is generated that changes only those 2 fields. You can also decide not to fetch large fields by excluding them from the fetch, see e.g.: https://www.llblgen.com/Documentation/5.10/LLBLGen%20Pro%20RTF/Using%20the%20generated%20code/Adapter/gencode_excludedfields_adapter.htm

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 08-May-2023 10:52:21   

martytheman wrote:

Is it possible to use "updatable views"? In SQL Server management studio you can have a view that only contains a subset of the fields needed.

A use case for this would be where you have
- a product list with approx. 10 fields ( just a subset of all fields ) and update what you need - the full product if you are editing a single product that contains large fields that contain HTML / descriptive text that you don't need to load / update with every change of some fields with the list.

You can save to a view (tho you have to switch the allowed actions on the mapping of the entity to create-retrieve-update-delete, otherwise it's seen as readonly. Updating a view might require you to write update triggers on the view tho, but that's up to you.

Frans Bouma | Lead developer LLBLGen Pro