SQL Server 2005 Express 中的这两行有什么区别?
DATEADD(d, 0, DATEDIFF(d, 0, @Today));
和
DATEADD(d, DATEDIFF(d, 0, @Today), 0);
除了使此语句随机失败之外:
DECLARE @DateSrc DATETIME;
-- Chop off the time part:
SET @DateSrc = DATEADD(d, 0, DATEDIFF(d, 0, @Today));
INSERT INTO dbo.SeqNo(MyGUID, TheDay, LastNo)
SELECT @MyGUID, @DateSrc, 0
WHERE NOT EXISTS (
SELECT 1 FROM dbo.SeqNo AS sn
WHERE sn.MyGUID = @MyGUID AND sn.TheDay = @DateSrc
);