T-SQL循环打印一年中所有的日期(WHILE循环)
DECLARE @price_date DATETIME
SET @price_date = CONVERT(DATETIME,'2007-01-01')
WHILE @price_date <= CONVERT(DATETIME,'2007-12-31')
BEGIN
PRINT CONVERT(CHAR(10), @price_date, 120)
SET @price_date=DATEADD(DAY, 1, @price_date)
END
SET @price_date = CONVERT(DATETIME,'2007-01-01')
WHILE @price_date <= CONVERT(DATETIME,'2007-12-31')
BEGIN
PRINT CONVERT(CHAR(10), @price_date, 120)
SET @price_date=DATEADD(DAY, 1, @price_date)
END