2010-02-22 72 views

回答

0

所有類型的INSTEAD OF觸發器一般不支持使用FILESTREAM表 - 和DELETE在這種情況下沒有什麼不同。原因可能是它在UPDATE觸發器和帶外更新(來自.Net或Win32)的情況下會有非常複雜的語義。

如果您提供了一些關於您的場景的更多細節,那麼也許有人可以給你一個解決方法。

+0

我可以通過刪除後觸發器修復它。 我剛剛在那裏插入。 Thx – k0ni 2010-02-23 09:00:54

1

您可以創建一個的兩個表istead:

CREATE TABLE [dbo].[FileStreams](
    [Id] [int] IDENTITY(1,1) NOT NULL, 
    [RowGuid] [uniqueidentifier] ROWGUIDCOL NOT NULL, 
    [Data] [varbinary](max) FILESTREAM NULL, 
    CONSTRAINT [PK_FileStreams] PRIMARY KEY CLUSTERED 
    (
     [Id] ASC 
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY], 
    UNIQUE NONCLUSTERED 
    (
     [RowGuid] ASC 
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 
) ON [PRIMARY] FILESTREAM_ON [FilestreamGroup] 
GO 

CREATE TABLE [dbo].[Files](
    [Id] [int] IDENTITY(1,1) NOT NULL, 
    [Name] [nvarchar](1024) NULL, 
    [FileStreamId] [int] NOT NULL, 
    CONSTRAINT [PK_Files] PRIMARY KEY CLUSTERED 
    (
     [Id] ASC 
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 
) ON [PRIMARY] 
GO 

ALTER TABLE [dbo].[Files] WITH CHECK ADD CONSTRAINT [FK_Files_FileStreams] FOREIGN KEY([FileStreamId]) 
REFERENCES [dbo].[FileStreams] ([Id]) 
GO 

ALTER TABLE [dbo].[Files] CHECK CONSTRAINT [FK_Files_FileStreams] 
GO 

外鍵必須是NO ACTION。它允許你創建INSTEAD OF觸發器的表文件