DECLARE @year VARCHAR(4) , @month CHAR(2), @Day CHAR(2) , @hr CHAR(2), @min CHAR(2) ,@Sec CHAR(2)
SELECT @Year = '2009', @month = '02', @Day = '01', @min = '10', @hr= '01', @Sec = '34'
SELECT CAST (@Year+@month+@Day+' '+@hr+':'+@Min+':'+@Sec AS datetime )
SELECT DATENAME(year, '2007-06-01 12:10:30.123')
,DATENAME(month, '2007-06-01 12:10:30.123')
,DATENAME(day, '2007-06-01 12:10:30.123')
,DATENAME(dayofyear, '2007-06-01 12:10:30.123')
,DATENAME(weekday, '2007-06-01 12:10:30.123');
SELECT DATENAME(hour, '2007-06-01 12:10:30.123')
,DATENAME(minute, '2007-06-01 12:10:30.123')
,DATENAME(second, '2007-06-01 12:10:30.123');