例如 - 我想在sql server中创建具有此查询结果的临时表,因为我在下面尝试过查询但是,我发现(?<!=)== [A-Za-z\s]+ ==(?!=)
“EmployeeID”列被多次指定为' ResultSet` 请帮忙。谢谢
'
答案 0 :(得分:1)
EmployeeID在您的select语句中出现两次,使用别名或删除其中一列。
SELECT
Employees.EmployeeID <-------
,Employees.LastName
,Employees.FirstName
,Employees.Title
,Employees.TitleOfCourtesy
,Employees.BirthDate
,Employees.HireDate
,Employees.Address
,Employees.City
,Employees.Region
,Employees.PostalCode
,Employees.Country
,Employees.HomePhone
,Employees.Extension
,Employees.Photo
,Employees.Notes
,Employees.ReportsTo
,Employees.PhotoPath
,Orders.OrderID
,Orders.CustomerID
,Orders.EmployeeID <-------
例如:
,Orders.EmployeeID as OrderEmployeeID
答案 1 :(得分:1)
您的临时表列名称将只是列名称。它不会包含您的表名。要回答您的问题,请从select语句中删除重复的列名称或提供别名。
SELECT
Employees.EmployeeID // this is enough
,Employees.LastName
,Employees.FirstName
,Employees.Title
,Employees.TitleOfCourtesy
,Employees.BirthDate
,Employees.HireDate
,Employees.Address
,Employees.City
,Employees.Region
,Employees.PostalCode
,Employees.Country
,Employees.HomePhone
,Employees.Extension
,Employees.Photo
,Employees.Notes
,Employees.ReportsTo
,Employees.PhotoPath
,Orders.OrderID
,Orders.CustomerID
// remove this line. Or use alias
,Orders.EmployeeID AS [Orders_EmloyeeID]
// ,Orders.EmployeeID
,Orders.OrderDate
,Orders.RequiredDate
,Orders.ShippedDate
,Orders.ShipVia
答案 2 :(得分:0)
更改部分Employees.EmployeeID as ID