如何从表A中显示5列,然后从表B中显示2列,然后在SQL Server连接中再次显示表A中的剩余coulmns

如何从表A中显示5列,然后从表B中显示2列,然后在SQL Server连接中再次显示表A中的剩余coulmns

问题描述:

How to show 5 columns from TABLE A, then 2 columns from Table B, then remaining coulmns from Table A again in a sql server join .

Follwing is my query.

SELECT DISTINCT A.*, B.local_time, B.creation_time FROM #SqlData A INNER JOIN @OracleInfo B ON A.event_id = B.GLOBALEVENTID

this order is specifically required to keep the similar columns together. And both the tables have really large number of columns. so i don't want to name them directly.

Please help me out.

如何从表A中显示5列,然后从表B中显示2列,然后再从表A中显示剩余库仑 一个sql server join。 p>

Follwing是我的查询。 p>

SELECT DISTINCT A. *,B.local_time,B.creation_time FROM #SqlData A INNER JOIN @OracleInfo B ON A.event_id = B.GLOBALEVENTID p> \ n

特别要求此顺序将类似的列保持在一起。 这两个表都有很多列。 所以我不想直接命名。 p>

请帮帮我。 p> div>

 SELECT DISTINCT A.COL1,A.COL2,A.COL3,A.COL4,A.COL5, B.local_time, B.creation_time, A.COL6, A.COL7, A.COLN FROM #SqlData A INNER JOIN @OracleInfo B ON A.event_id = B.GLOBALEVENTID

You will have to specifically mention column names in SELECT list. This can,t be done using * in select list which selects all the columns.