我想从一个有两个字段的表中选择
标记标记查询(名称) SELECT Name From table_employee where empid=1
结果我想要一张像
标记 标记结果(名称) Tom
所以我想执行我从选择中检索的查询并将其结果存储在我的表中而不是查询中
Update #TempTagQueries
SET TagQuery = CAST(#Temp2.EmailTagQuery AS varchar(MAX))
FROM #TempTagQueries AS #Temp1
INNER JOIN
(SELECT EmailTagQuery,EmailTagIdentifier FROM tblEmailTag) AS #Temp2
ON #Temp1.TagValue = #Temp2.EmailTagIdentifier
SELECT * FROM #TempTagQueries
如果可以这样做,或者如果不能,请帮助我,解决方案是什么。因为我避免使用光标来做到这一点。
Update #TempTagQueries
SET TagQuery = EXEC( CAST(#Temp2.EmailTagQuery AS varchar(MAX)))
FROM #TempTagQueries AS #Temp1
INNER JOIN
(SELECT EmailTagQuery,EmailTagIdentifier FROM tblEmailTag) AS #Temp2
ON #Temp1.TagValue = #Temp2.EmailTagIdentifier
SELECT * FROM #TempTagQueries