Merge into Using

https://www.cnblogs.com/renxiaoren/p/5442352.html

 

 

DECLARE @Reader_temp TABLE (AID INT)

--2.具有阅读权限流程
MERGE INTO @Reader_temp
USING (SELECT DISTINCT MainAID FROM td_YWZC_Main_Reader WHERE UserName=@UserName ) R
ON AID=R.MainAID
when not matched  then  insert(AID) values(R.MainAID);

 是插入到表变量后再查询

 

posted @ 2021-03-11 12:58  三生石头花  阅读(147)  评论(0编辑  收藏  举报