On Fri, 20 Jan 2006 09:48:29 +0100, Otto Miros wrote:
Hi Otto,
I have no idea. I took your code, added some missing bits (like the view
definition, the insertion of some rows in t2 to see if they are updated
or not and the insert statement into the view to test things), and it
did what I expected it to do. Just copy and paste the code below into
Query Analyzer or Management Studio and execute it.
-- Your table definitions
CREATE TABLE [t1] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[name] [char] (10)
)
CREATE TABLE [t2] (
[ID] [int] IDENTITY (1, 1) NOT NULL ,
[name] [char] (10)
)
-- Make sure something is in table t2
INSERT INTO t2 (name)
VALUES ('john')
INSERT INTO t2 (name)
VALUES ('george')
-- Check it
SELECT * FROM t2
go
-- Add the view (absent in your post)
CREATE VIEW v1
AS
SELECT name
FROM t1
go
-- Create the trigger
CREATE TRIGGER trv1 ON [dbo].[v1]
INSTEAD OF Insert
AS
update t2 set name = 'paul'
go
-- Attempt an insert
INSERT INTO v1 (name)
VALUES ('ringo')
-- Check results. First t1
SELECT * FROM t1
-- Next t2
SELECT * FROM t2
go
-- Clean up
DROP VIEW v1
DROP TABLE t1
DROP TABLE t2
go
Maybe you can explain in some more detail what you did, then I can try
and reproduce it here and look for a fix.
--
Hugo Kornelis, SQL Server MVP
|