We help IT Professionals succeed at work.
Get Started

Using a query in an if statement

spinzr0
spinzr0 asked
on
251 Views
Last Modified: 2021-04-21
I need to use an if statement to determine if one value is a 1 or 0.  If its a one, the query should be X, otherwise it should be y.  The easiest way to explain it is how I assumed the query would be:

IF(SELECT DEFAULT_EMAIL_LIMITS FROM [AD].[dbo].[V_1] = 1)
    SELECT [LOGON_ID],[EMAIL_SERVER],[DEFAULT_EMAIL_LIMITS],[WARNING_LIMIT],[SEND_LIMIT],[SEND_RECEIVE_LIMIT] FROM [AD].[dbo].[V_1]
ELSE
    SELECT [LOGON_ID],[EMAIL_SERVER],[DEFAULT_EMAIL_LIMITS],'default' as WARNING_LIMIT,'default' as SEND_LIMIT,'default' as SEND_RECEIVE_LIMIT FROM [AD].[dbo].[V_1]

If this isn't clear please let me know and I can explain more
Comment
Watch Question
CERTIFIED EXPERT
Expert of the Quarter 2010
Expert of the Year 2010
Commented:
This problem has been solved!
Unlock 2 Answers and 4 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE