WITH Emp AS (SELECT acc.* FROM GXSpreadDB.dbo.gxs_account acc LEFT JOIN RYAccountsDB.dbo.AccountsInfo Account ON acc.userid=Account.userid WHERE parentuserid=7123 AND Account.AgentID=0 UNION ALL SELECT d.* FROM Emp ,GXSpreadDB.dbo.gxs_account d WHERE d.parentuserid =Emp.userid ), DaiLi_RelationalTree AS ( select * from GXSpreadDB.dbo.gxs_account where gameid=208356 ) --select * from DaiLi_RelationalTree select * from Emp,DaiLi_RelationalTree
The above code is not the problem.
This code will report object does not exist. You may be inserted into a temporary table to repeat the query bar
WITH Emp AS (SELECT acc.* FROM GXSpreadDB.dbo.gxs_account acc LEFT JOIN RYAccountsDB.dbo.AccountsInfo Account ON acc.userid=Account.userid WHERE parentuserid=7123 AND Account.AgentID=0 UNION ALL SELECT d.* FROM Emp ,GXSpreadDB.dbo.gxs_account d WHERE d.parentuserid =Emp.userid ), DaiLi_RelationalTree AS ( select * from GXSpreadDB.dbo.gxs_account where gameid=208356 ) select * from DaiLi_RelationalTree select * from Emp,DaiLi_RelationalTree