创建一个临时表以在其上进行左外部联接 [英] creating a temp table to do a left outer join on

查看:81
本文介绍了创建一个临时表以在其上进行左外部联接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个查询,现在需要创建一个临时表.它将包含以下字段.我以为我记得如何完成此任务,但是它没有运行.如果我注释掉"IF"和""INTO"行.
如果OBJECT_ID(' tempdb ..#lstLeft')不是空的删除表#lstLeft

I created a query and now need to create a temporary table. It will contain the below fields. I thought I remembered how to complete this task but it doesn''t run. The Query runs fine if I comment out the "IF" & "INTO" lines.
IF OBJECT_ID ('tempdb..#lstLeft') is not null drop table #lstLeft

SELECT
       SStaff.StaffName,
       PatientProviders.ProviderRole,
       SPatient.PatientName,
       Immunization.ImmunizationDateTime,
       Team.ServiceSection,
       Immunization.VisitDateTime,
       SPatient.PhoneResidence,
       SPatient.PhoneWork,
       SPatient.DateOfBirth,
       SPatient.Age,
       SPatient.Gender,
       SPatient.PatientSID
  INTO #lstLeft
  FROM /* the table and fields work fine in the query not trying to create a tempdb */

推荐答案

我遇到了同样的问题,这对我来说也很奇怪.

我通过将临时表名重命名为一个新的表名解决了这个问题,然后突然起作用了!

因此,请尝试重命名 #lstLeft ALL 个实例,然后重试.

您的操作方式是正确的.
I encountered the same problem and It was strange for me too.

I solved this problem by renaming the temporary table name to a new one and suddenly it worked !

So try to rename ALL instances of #lstLeft and try again.

Your way of doing it is correct.


这篇关于创建一个临时表以在其上进行左外部联接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆