使用内联更新查询

Update Query With Inline

是否可以像这样进行更新查询?可能不是,只是我的一个想法 可能 解决我可怕的数据结构困境的方法。我想要完成的是:

要更新 table 产品信息,其中条目类型存在于 table vet

Set @location varchar(100), @entrydate datetime
Set @location = 'server01.database01.dbo.manhunt
Set @entrydate = GetDate()  

Update prodinformation
Set totalenteredtoday = abc.te
FROM prodinformation d
JOIN (SELECT Count(ID) 
      from @location 
      WHERE entrytype IN (
                          Select validentrytype 
                          from vet
                          where ltrim(rtrim(entrydate)) = @entrydate) As te
Update  d
Set     totalenteredtoday = te.IdCount
FROM    prodinformation As d
        JOIN 
        (
            Select   [someJoinAttribute]
                    ,Count(ID) As IdCount
            From    @location 
            Where   entrytype IN (  Select  validentrytype 
                                    From    vet With (Nolock)
                                    Where   ltrim(rtrim(entrydate)) = @entrydate
                                 )
            Group By [someJoinAttribute]
        ) As te On d.[someAttribute] = te.[someJoinAttribute]

此处 [someJoinAttribute] 将是用于执行连接操作的 column/attribute