【发布时间】:2014-10-26 21:43:29
【问题描述】:
如果我有疑问
select * into #tmp1 from dbo.t1 inner join dbo.t2 on t1.Sender_Id=t2.Id
我收到一个错误
Column names in each table must be unique. Column name 'Id' in table '#tmp1' is specified more than once.
我怎样才能不求助于同样的事情
select t1.Id as t1id, t1.col2. ... t1.col30, t2.Id as t2id, ... t2.col40 as t2col40 from ...
符号。
我只需要快速手动检查几个表,所以我想要一种快速检查连接的方法。
【问题讨论】:
-
不幸的是,如果有重复的列,您需要在使用
SELECT * INTO时解决这个问题 -
如前所述。你不能。您将需要指定列名并确保它们是唯一的。但是,而不是使用'SELECT * INTO'。您可以事先显式创建表(使用唯一的列名)并改为执行“INSERT INTO”。这允许您仍然使用 SELECT *。