August 9, 2006 at 3:46 am
Hi
Is it possible to use set or if keywords in a view
Thanks
August 9, 2006 at 4:30 am
Hi,
no, it is not possible. You can only include a select statement in a view.
If you're looking to use the SET statement then you want to perform an update so you should consider using a procedure instead. You can however update the view under certain conditions - check BOL for specific conditions under which a view can be updated.
Likewise, you cannot use IF in a view. Again, consider using a stored procedure - or possibly a function.
Hope that helps,
August 9, 2006 at 6:41 am
Vandy,
As Carl pointed out, you cannot use SET or IF. A view must consist of only 1 SELECT statement or the UNION of several SELECTs (don't believe that will be updateable).
Instead of using IF, you can use CASE. CASE may be used in the SELECT list and in the WHERE clause (with some caution).
Once you have the view returning everything you want, you can use additional criteria in the WHERE clause of a SELECT that uses the view in the FROM clause.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 9, 2006 at 7:16 am
Thanks a lot ...........
These are useful ans.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply