Sql server® 2012 t-sql fundamentals


  Today is the last day of the year. 2



Download 10,93 Mb.
Pdf ko'rish
bet379/443
Sana26.01.2022
Hajmi10,93 Mb.
#411755
1   ...   375   376   377   378   379   380   381   382   ...   443
Bog'liq
BookSQL

1. 

Today is the last day of the year.



2. 

Today is the last day of the month but not the last day of the year.



3. 

Today is not the last day of the month.

www.it-ebooks.info



346  

Microsoft SQL Server 2012 T-SQL Fundamentals

IF YEAR(SYSDATETIME()) <> YEAR(DATEADD(day, 1, SYSDATETIME())) 

  PRINT 'Today is the last day of the year.'; 

ELSE 

  IF MONTH(SYSDATETIME()) <> MONTH(DATEADD(day, 1, SYSDATETIME())) 



    PRINT 'Today is the last day of the month but not the last day of the year.'; 

  ELSE 


    PRINT 'Today is not the last day of the month.';

If you need to run more than one statement in the IF or ELSE sections, you need to use a state-

ment block. You mark the boundaries of a statement block with the BEGIN and END keywords. For 

example, the following code shows how to run one type of process if it’s the first day of the month, 

and another type of process if it isn’t.

IF DAY(SYSDATETIME()) = 1 

BEGIN 

  PRINT 'Today is the first day of the month.'; 



  PRINT 'Starting first-of-month-day process.'; 

  /* ... process code goes here ... */ 

  PRINT 'Finished first-of-month-day database process.'; 

END 


ELSE 

BEGIN 


  PRINT 'Today is not the first day of the month.'; 

  PRINT 'Starting non-first-of-month-day process.'; 

  /* ... process code goes here ... */ 

  PRINT 'Finished non-first-of-month-day process.'; 

END


Download 10,93 Mb.

Do'stlaringiz bilan baham:
1   ...   375   376   377   378   379   380   381   382   ...   443




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish