Solved

Clueless about the right syntax. (GETDATE)

Posted on 2011-03-17
2
247 Views
Last Modified: 2012-05-11
Question: I would like to use GETDATE() in combination with IF THEN.

SELECT datepart(mm,getdate()) WHEN 1 print ''yada yada yada" ELSE print "yoda yoda yoda"

Since I'm a noob with SQL I can't seem to get the notation right.
I have searched myself silly on the web for the answer but with no luck.
Could someone tell me what the correct notation should be?

Thanks in advance!

Best regards,
Clyde.
0
Comment
Question by:Clyde_Radcliffe
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 35155955
check out this:

SELECT CASE datepart(mm,getdate()) WHEN 1 THEN 'yada yada yada' ELSE 'yoda yoda yoda' END

Open in new window


resp:

declare @res varchar(100) 
SELECT CASE datepart(mm,getdate()) WHEN 1 THEN 'yada yada yada' ELSE 'yoda yoda yoda' END
print @res

Open in new window

0
 

Author Comment

by:Clyde_Radcliffe
ID: 35155990
@angelllll: Excellent! Thanks for the help!!!
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now