tags:

views:

33

answers:

2

I am using a function in the view for getting some result sets. In that function, based on some condition need to update rows to the database table.

Can anyone tell me, How can I do this

+1  A: 

You cannot do this using SQL Server. SQL Server does not allow Update/Delete/Insert statements in UDFs. I think you are also prevented from calling a stored procedure as well.

Randy Minder
Is there any work around for this?
Govindan
@Govindan: not at all. Randy is 100% correct
gbn
No work around. SQL Server does not allow functions to do Inserts/Updates/Deletes. You're going to have to do your data modifications within a stored procedure.
Randy Minder
A: 

SPs can read, write, delete, and update permanent tables.But you must be considerable if you wanna update rows in the base table (tables) of the view because there are some restrictions

Balend
@Balend - You didn't read the question closely. He wants to update rows inside a UDF. This isn't allowed by SQL Server.
Randy Minder
I suggest possible solution to problem at general
Balend