我创建了一个用于填充下拉列表的存储过程。但是 order by 子句不适用于我的程序。
ALTER PROCEDURE proc
-- Add the parameters for the stored procedure here
@compID bigint,
@after datetime
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
CREATE TABLE #tmpAuc ( ProjectID BIGINT, Title VARCHAR(256))
INSERT INTO #tmpAuc
SELECT SA.ID ProjectID, SA.Title
FROM [dbo].[Sessions] S
INNER JOIN Auc SA ON S.AucID = SA.ID
WHERE S.Session < 3 AND SA.Status > 0 AND SA.CompanyID = @companyID AND S.LiveBeginDate > @after
ORDER BY LiveBeginDate
SELECT DISTINCT * FROM #tmpAuc
END
我想按 LiveBehinDate 的降序排序