Saturday, February 25, 2012

Can I Use If Condition In View

HiiiALL..
I AM CREATING A VIEW AND USE IN THIS IF AND ELSE CONDITION.
THIS SYNTAX IS NOT WORKING PROPERLY..CAN USE OR NOT??No, you can not use IF condition in a view.
There are so many other ways to do it.

Thank you.|||

Quote:

Originally Posted by iburyak

No, you can not use IF condition in a view.
There are so many other ways to do it.

Thank you.


thank u sir for reply
u say that there is many ways.
so sir what is the other way..|||1. You can create a table function.
2. You can return result of a stored procedure.
3. You can use where condition on existing view.
4. You can use Case in select statements of a view which is in many cases is almost the same as IF ELSE.
5. You can create different views and use them depend on a conditions like.
Create view View_StoredProcs
AS
select name from sysobjects where type like 'p'

Create view View_Tables
AS
select name from sysobjects where type like 'u'

and more....|||Hi iburyak,

I've used the case statement and it is working as expected here.

Thanks for the excellent explanation.|||

Quote:

Originally Posted by leniel

Hi iburyak,

I've used the case statement and it is working as expected here.

Thanks for the excellent explanation.


You are welcome.
For generic question I had a generic answer.
I am glad you were able to get some info out of it... :)
Good Luck.

No comments:

Post a Comment