IF object_id (' tempdb.. #t ') is not a NULL DROP TABLE #t
GO
CREATE table #t (ID int identity,dt varchar (10))
Go
DECLARE @starttime datetime, @endtime datetime
Set @starttime = ' 2010-5-01 '
Set @endtime = ' 2010-5-31 '
Select number from Master. Spt_values
Where number between 0 and DateDiff (day, @starttime, @endtime) and type= ' P '
---results are as follows:
After the creation of the temporary table, but this table does not open the Oh!
Master.. Spt_values table cannot find, do not know is my own reason or really do not have this table ...
Record several functions that you seldom use
ISNULL (Check_expression, Replacement_value) replaces Null,isnull () with the specified replacement value, or it can be lowercase.
DATEDIFF (datepart,startdate,enddate) the DATEDIFF () function returns the number of days between two dates, and the case is available
Convert (data_type (length),data_to_be_converted,style) Converts the data type, where the style is worth noting, usually less used
SQL Server 2005 Table master: Spt_values