[英]SQL - Insert Stored Procedure Results into Temp Table
I have a fully working stored procedure grabbing data from different tables using joins. 我有一个完全正常的存储过程,可以使用联接从不同的表中获取数据。 I am currently using the below SELECT statement to select the data I require: 我目前正在使用下面的SELECT语句来选择所需的数据:
SELECT
ClientReference, ReferenceNumber, Text3,
ReceiptDate, [dbo].[Complaint].[Description],
ActionTaken, dbo.Category.Name, dbo.CategoryOption.FullName,
dbo.Complaint.AuditCreatedBy,
dbo.UserGroup.Name, dbo.Complaint.LoggedByUserId,
dbo.Complaint.LoggedByTime
FROM
dbo.Complaint
Now what I want to be able to do is insert this data into a temporary table. 现在,我想做的就是将这些数据插入临时表中。 However, INSERT INTO
does not work as I have two columns (resulting from my join) called Name
. 但是, INSERT INTO
不起作用,因为我有两个列( Name
来自我的联接),称为Name
。
How would I go about solving this? 我将如何解决这个问题?
Just alias one of the Name
columns: 只是别名之一的Name
列:
SELECT
ClientReference,
ReferenceNumber,
Text3,
ReceiptDate,
Complaint.Description,
ActionTaken,
Category.Name As CategoryName,
CategoryOption.FullName,
Complaint.AuditCreatedBy,
UserGroup.Name,
Complaint.LoggedByUserId,
Complaint.LoggedByTime
INTO #tempTable
FROM
dbo.Complaint
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.