Advertisement
EmilianoRoldanR

Cambiar area a todos los productos de un subgrupo determinad

Aug 24th, 2019
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.85 KB | None | 0 0
  1. --Cambiar area a todos los productos de un subgrupo determinado
  2.  
  3. Cambia el área de impresion de todos los productos que pertenecen a determinado sub-grupo
  4.  
  5. DECLARE @variable INT, @variable2 INT
  6.  
  7. SELECT @variable=idsubgrupo FROM subgrupos WHERE descripcion = '**SUBGRUPO**'; /* DEVUELVE ID DEL SUB GRUPO Y LO ALMACENA EN UNA VARIABLE */
  8.  
  9. /*select idproducto from subgruposproductos where idsubgrupo= @variable;*/ /* DEVUELVE LOS PRODUCTOS DENTRO DE ESE SUBGRUPO*/
  10.  
  11. SELECT @variable2=idarea FROM areas WHERE nombre = '**AREAIMPRE**'; /* DEVUELVE ID DE UN AREA DE IMPRESION Y LO ALMACENA EN UNA VARIABLE */
  12.  
  13. /* CAMBIA EL AREA DE IMPRESION ACTUAL POR LA QUE EL USUARIO DESEE (EN ESTE CASO, LA QUE BUSCO ANTERIORMENTE)*/
  14. UPDATE productosdetalle SET idarea=@variable2 WHERE idproducto IN (SELECT idproducto FROM subgruposproductos WHERE idsubgrupo= @variable);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement