View Full Version : How can you prevent that SQL Server deletes related records in a view?


SON
01-24-2006, 11:34 AM
:confused: Hi,
I am new to SQL-Server and just transferred my very complex Access database over. In Access it was possible to design a query of two related tables joined by a "one to many" relationship and delete the "many side" record without deleting the "one side" table record.
Now I tried to design a View in SQL server and if I try to delete a record in that view I get an error message saying that there are related records on the "one side" and deleting is not possbile.
Could somebody help please ...?

SQL_Hell
01-24-2006, 12:22 PM
Hi,

Views are not for deletes only selects

either use query analyzer (if not permanent) or create a stored proc

also

are you aliasing the table correctly?

SON
01-25-2006, 02:45 AM
Hi SQL Hell,
Thanks for your quick reply! :)
What did you mean with aliasing the table correctly?

SQL_Hell
01-25-2006, 02:04 PM
I meant something like this.....


delete a
from table1 a inner join table2 b on a.id = b.id