Groups | Blog | Home
all groups > sql server programming > march 2004 >

sql server programming : Case statements


MBurns
3/16/2004 9:39:42 PM
Hi, I've created a view that uses a CASE statement to set
the value of a field depending on the value of another
field. The view is created ok however I need the view to
be updateable and this isn't the case at the moment. Is
there another way to approach this problem so that I do
get an updateable view? My basic needs are:

1. Check the purchasing status field in an orders table (1
is being purhased solely by the main contact and 2 is
being purchased by the main contact and partner)

2. If 1 then display the main contact's name in a field
called 'Buyer' in the view.

3. If 2 then display the partner's name in the 'Buyer'
field.

MBurns
3/16/2004 10:03:30 PM
Don't worry I've worked this out. My view included sub
views that contained TOP 100 PERCENT statements. I took
these out and then it worked.


[quoted text, click to view]
Greg Obleshchuk
3/17/2004 4:46:14 PM
Hi Monty,
I would not recommend using a view to update your data. You should be using
an SP to update your data or update the table directly via an update
statement using the PK to select the row.
Just because you can update via a view doesn't mean you should, the overhead
will always be more that an SP or update to table statement.

-----------------
I hope this helps

Greg O

[quoted text, click to view]

AddThis Social Bookmark Button