SQL IF statement

I would like to create a stored procedure which pulls different data depending on the @Type that i provide.

Is there a way to use "IF" logic within an SQL statement?
jjexpert1Asked:
Who is Participating?
 
Ashish PatelConnect With a Mentor Commented:
Yes
use like this

If @Type = 'somevalue'
Begin
        'do statement
        'do statement
End
Else
Begin
        'do statement
        'do statement
End
0
 
Ashish PatelCommented:
Or Try using Case @Type = 'somevalue' Then 'something' Else 'something' End
0
 
Ashish PatelCommented:
Sorry it should be like
Case When @Type = 'somevalue' Then 'something' Else 'something' End
0
All Courses

From novice to tech pro — start learning today.