--Here this script is check weather give year is leap year or not.
declare @year int
declare @isLeapYear bit
set @isLeapYear = 'false'
set @year = 2004
print 'Given year is : ' + cast(@year as varchar)
if(@year % 4 = 0)
set @isLeapYear = 'true'
if(@year % 100 = 0)
if(@year % 400 = 0)
set @isLeapYear = 'false'
if(@isLeapYear = 'true')
print cast(@year as varchar) + ' is a leap year.'
else
print cast(@year as varchar) + ' is not a leap year.'
Output will be...
Given year is : 2004
2004 is a leap year.
About Me
-
Anil Desai.
Software Engineer
T M Technologies
જય વાળીનાથ - T-SQL is a basic of structure query language. So I always want to learn T-SQL in different way to get best performance in query. And its my passion.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment