我有一个存储过程,将新增日期给出的最新记录,即,为了这是我的程序....
select distinct top 5 videos.videoid,videos.videotitle,videos.videoname,
convert(varchar,videos.posteddate,106) as posteddate,videos.approvedstatus,
videos.videoimage,(ISNULL(videos.views,0.0)) as [views],videos.privacy,
(isnull(videos.rating,0.0)) as rating,videos.userid,
users.userid,users.username from videos left outer join users on
videos.userid=users.userid
where videos.approvedstatus='Y' and videos.privacy='P'
order by posteddate desc
但它不给最新记录
当我执行查询
select * from videos order by posteddate desc
它给确切的记录。 但存储过程是不给确切的记录。 u能帮助我,谢谢。
使用ORDER BY videos.posteddate
select distinct top 5
videos.videoid,
videos.videotitle,
videos.videoname,
convert(varchar,videos.posteddate,106) as posteddate,
videos.approvedstatus,
videos.videoimage,
(ISNULL(videos.views,0.0)) as [views],
videos.privacy,
(isnull(videos.rating,0.0)) as rating,
videos.userid,
users.userid,users.username
from
videos
left outer join
users on videos.userid=users.userid
where
videos.approvedstatus='Y' and videos.privacy='P'
order by
videos.posteddate desc
你原来是的equivalant ORDER BY convert(varchar,videos.posteddate,106) DESC
那么,你是通过“日星期一YYYY”字符串,而不是所期望的实际日期时间(YYYY-MM-DD HH等)排序
我想这是SQL Server 2000中:从内存中的SQL Server 2005不会接受这种不确定性