DECLARE @TABLENAME UD_DESCRIPCION
DECLARE @TYPE CHAR(1)
DECLARE @CADENA VARCHAR(100)

DECLARE TABLAS CURSOR FOR SELECT TABLENAME,TYPE FROM SH_SHIPPINGTABLES

OPEN TABLAS

FETCH NEXT FROM TABLAS INTO  @TABLENAME,@TYPE 
WHILE @@FETCH_STATUS = 0
BEGIN
	
	SET @CADENA= CASE @TYPE WHEN 'M' THEN 'UPDATE '+@TABLENAME+' SET STKNEW=1,STKSEND=0,STKMODIFY=0 '
				WHEN 'T' THEN 'UPDATE '+@TABLENAME+' SET STKSEND=0 '
				WHEN 'S' THEN 'UPDATE '+@TABLENAME+' SET STKNEW=1,STKSEND=0,STKMODIFY=1 '
				END
--	SELECT (@CADENA)
	EXEC (@CADENA)

	FETCH NEXT FROM TABLAS INTO  @TABLENAME,@TYPE 
END

CLOSE TABLAS

DEALLOCATE TABLAS



