exec sp_addlinkedserver 'linkstat', ' ', 'SQLOLEDB ', 'ip' exec sp_addlinkedsrvlogin 'linkstat', 'false ',null, 'uid', 'pwd' SELECT Ta.Company,Ta.PriseName,Ta.PriseName2,Ta.PriseName3,Ta.Account,Ta.MemberGUID into #temp2 FROM linkstat.[HC_Enter].[dbo].[T_ActivityLogs] Ta,linkstat.[HC_Enter].[dbo].[T_EnterpriseInfo] Tb where Tb.MemberGUID=Ta.MemberGUID and Ta.ActivityName='新春转盘大抽奖' and Tb.MemberType=0 select Te.Company,Te.PriseName,Te.PriseName2,Te.PriseName3,Te.Account,hu.u_RealName from [HC_HHR].dbo.[h_Company] hc, [HC_HHR].dbo.[h_UserInfo] hu, #temp2 Te where hc.c_u_id=hu.u_id and Te.MemberGUID=hc.c_MemberGUID drop table #temp2 exec sp_dropserver 'linkstat', 'droplogins'