I want to write to different tables depending on the state of my development (b=backup, t=testing).
The minimal example showing the problem is the following:
SELECT s.Monat FROM (
SELECT 'b' as mode, * FROM [BACKUP].IstMonat
UNION
SELECT 't' as mode, * FROM [TESTING].IstMonat
) s
where s.mode = 't' -- in the real world discovered by a sub query.
How can i create such a view that is actually writable?
Currently ...
INSERT INTO TestView(Monat) VALUES (1);
... results in ...
Msg 4406, Level 16, State 1, Line 1
Update or insert of view or function 'TestView' failed because it contains a derived or constant field.