1
All right Guys,
I have a table with stock of products from a network of 13 stores. I want to block items that have no stock in any store and that have not had sales in the last year or that have only been registered, but have not sold. I tried the script below:
UPDATE PRXLJ
SET Flg_BlqCom = 1, Flg_BlqVen = 1
WHERE Qtd_Saldo= 0
AND (YEAR(Dat_UltVen) <2017
OR Dat_UltVen IS NULL)
where:
- Flg_blqcom = 1 blocked for purchase
- Flg_blqven = 1 blocked for sale
- Flg_blqcom = 0 unlocked for purchase
- Flg_blqven = 0 unlocked for sale
The problem is that even in the central server the stocks are distributed in the table store by store and do not want to block if you have at least one unit in any branch. the same product code repeats 13 times, one for each store. When I ran this script he blocked the products according to the stock and last sale of each store, blocking a product in some stores and others not.
The structure of the table looks like this:
I need a script that blocks only the product that has no stock in any store and that has not been sold after 01/01/2017 in any store as well.
Using Sql Server 2008 This table has around 60 thousand items (considering that there are 13 stores, are around 780mil lines) and I want to leave unlocked some 15 thousand items or less that are actually active. For tax reasons I can’t delete old items, just block them. I don’t know if the information was enough for understanding, but if you need more information let me know.
They are different servers ? you can select on each server ? if yes you will need to make a Join between the tables of the servers making your Where and ands home a ... a very laborious case but it will be necessary.
– Marco Souza
Check this select ... https://stackoverflow.com/a/1144070/2740371. you will need to update based on the tables of each affiliate server..
– Marco Souza
@Gpdias SQL Server version is 2008 or 2008 R2? Enterprise edition?
– José Diz
The version is 2008 R2 @Josédiz. Each store has a server, but registration changes are made on a central server that is in the office. In it the table PRXLJ has the stock of all the stores. If the change is made in the branch the system has a Sync that will update according to what is on the central server. Then changes to the branch server have no effect, as the registry will be reinstated after the synchronization is complete.
– GPDias