ALTER TABLE VS4TInventory ADD
	TInvSpecialFlag smallint NULL
GO
update vs4tinventory set tinvspecialflag=0
GO
update vs4tinventory set tinvspecialflag=(select count(tecmln) from vs4tempworkcountmb where  tecmtwrmcode<>'' and tecmtwrmcode is not null and tecmrefno=tinvno)
GO
update vs4tinventory set tinvspecialflag=1 where tinvspecialflag>1
GO
update vs4tinventory set tinvspecialflag=0 where tinvspecialflag is null
GO