Home All Groups Group Topic Archive Search About

Return 1 of 2 Select Statements

Author
27 Apr 2007 12:57 AM
Derek Hart
I simply want to do this in a stored procedure:

If @myValue = 1
    Select Field1 From myTable
Else
If @myValue = 2
    Select Field1, Field2 From myTable

In query analyzer I get the right select statement, but in dotnet or access
I get only the first select statement, unless I change it to this:

If @myValue = 1
    Select Field1 From myTable
    Return
Else
If @myValue = 2
    Select Field1, Field2 From myTable
    Return

Now adding the returns made this work, but I am not sure why.  Any solid way
to do this?

Derek

AddThis Social Bookmark Button