Reset Workperiod ID

hellow, i will like to know how to reset to 0 JUST the workperiod ID

Clearing transactions with clear db transactions scripts does this.
Dont think you can reset wp without clearing transactions since they will be linked.
The clear db transactions script only clears transactional data. Products and settings etc remain.

You can reset it by running the following query.

Don’t forget to take a backup first!

DELETE FROM [WorkPeriods]
GO
DBCC CHECKIDENT ('WorkPeriods',RESEED,0)  
GO

Are you sure this is safe to do on it’s own without clearing tickets and orders etc?

Do not do that unless you know what your doing. You will wreck your system and reports.

The person who wants to do that is already taking some risks.
I’m using it to reset after the pre-installation trials.

If you want delete tickets, orders, etc too, you can use like that;

Databank Transaktionen_with_IndexReset.zip (592 Bytes)

You can use that only under Sql Management Studio (not as task or CB etc)

TRYING AND USING are your own risk

That’s not quite what I meant, I was questioning the offer of sql to reset wp id without clearing transactions as would imagine it would be problematic with table relationships referencing wpid.

I think the friend who is asking the question is just wanting to reset the WP ID, because everything else has already can be reset in the default task.

1 Like

I would suggest using Database Tools to clear this:

This task can’t reset WP ID.

It can if you modify it and add the SQL for it. Its just a file in documents folder.

1 Like

I have tried this before, but unfortunately it does not work when in SambaPos with default task commands. But it works in SSMS.

It works i use it. I’m curious why not for you though. What I mean is you can edit the default task. Those are just SQL scripts.

Just edit the files in documents\SambapoS5\database tasks folder. Add the SQL to end of the task.

Edit the [CBL]Clear Database Transactions file located in your \Documents\SambaPOS5\Database Tasks folder and add the following:

DELETE FROM [TicketEntities]
GO
DELETE FROM [Tickets]
GO
DELETE FROM [AccountTransactionDocuments]
GO
DELETE FROM [AccountTransactions]
GO
DELETE FROM [AccountTransactionValues]
GO
DELETE FROM [Calculations]
GO
DELETE FROM [CostItems]
GO
DELETE FROM [InventoryTransactionDocuments]
GO
DELETE FROM [InventoryTransactions]
GO
DELETE FROM [Orders]
GO
DELETE FROM [PaidItems]
GO
DELETE FROM [PeriodicConsumptionItems]
GO
DELETE FROM [PeriodicConsumptions]
GO
DELETE FROM [ProductTimerValues]
GO
DELETE FROM [Payments]
GO
DELETE FROM [WarehouseConsumptions]
GO
DELETE FROM [WorkPeriods]
GO
UPDATE [Numerators] SET Number = 0
GO
UPDATE [EntityStateValues] SET EntityStates = '[{"S":"Available","SN":"Status"}]' Where EntityStates like '%Status%'
GO
DBCC CHECKIDENT ('WorkPeriods',RESEED,0)  
GO
1 Like

I tried this in 5.2.20 version, it didn’t work. Now I tried again with 5.2.26 and it worked … Interesting

Ive used this trick since v4 days.

1 Like

In addition to the default task, I use the following queries.

DBCC CHECKIDENT ('WorkPeriods',RESEED,0)  
GO
DBCC CHECKIDENT ('TicketEntities',RESEED,0)  
Go
DBCC CHECKIDENT ('Tickets',RESEED,0)  
GO
DBCC CHECKIDENT ('AccountTransactionDocuments',RESEED,0) 
GO
DBCC CHECKIDENT ('AccountTransactions',RESEED,0)  
GO
DBCC CHECKIDENT ('AccountTransactionValues',RESEED,0)  
GO
DBCC CHECKIDENT ('Calculations',RESEED,0)  
GO
DBCC CHECKIDENT ('CostItems',RESEED,0)  
GO
DBCC CHECKIDENT ('InventoryTransactionDocuments',RESEED,0)  
GO
DBCC CHECKIDENT ('InventoryTransactions',RESEED,0)  
GO
DBCC CHECKIDENT ('Orders',RESEED,0)  
GO
DBCC CHECKIDENT ('PaidItems',RESEED,0)  
GO
DBCC CHECKIDENT ('PeriodicConsumptionItems',RESEED,0)  
GO
DBCC CHECKIDENT ('PeriodicConsumptions',RESEED,0)  
GO
DBCC CHECKIDENT ('ProductTimerValues',RESEED,0)  
GO
DBCC CHECKIDENT ('Payments',RESEED,0)  
GO
DBCC CHECKIDENT ('WarehouseConsumptions',RESEED,0)
GO
3 Likes