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

DECLARE TABLAS CURSOR FOR SELECT TABLENAME,TYPE FROM SH_SHIPPINGTABLES where type <>'X' order by sequence desc

OPEN TABLAS

FETCH NEXT FROM TABLAS INTO  @TABLENAME,@TYPE 
WHILE @@FETCH_STATUS = 0
BEGIN
	
	IF(@TYPE='M' ) 
		SET @CADENA= 'update '+@TABLENAME+' SET STKNEW=1,STKMODIFY=0,STKSEND=0 '	
	ELSE
		SET @CADENA= 'update '+@TABLENAME+' SET STKSEND=0 '	
	
	EXEC (@CADENA)

	FETCH NEXT FROM TABLAS INTO  @TABLENAME,@TYPE 
END

CLOSE TABLAS

DEALLOCATE TABLAS

go

--update sh_shippingtables set sequence = 207 where tableid='107'
--select * from sh_shippingtables where type <>'X' and type='M' order by sequence  



