SQL Server视图中删除重复项

时间:2018-09-19 15:49:03

标签: sql-server

WITH CTE AS
(
    SELECT  
        [account],
        [loan],
        [document_category],
        [document_comments],
        [document_description], 
        [document_placeholder_name],
        [document_status],
        [file_Name],
        [Document ID],
        [File Path],
        RN = ROW_NUMBER() OVER (PARTITION BY [File Path] ORDER BY [File Path])
    FROM 
        (view location)
)
DELETE FROM CTE 
WHERE RN > 1

此代码在表上使用时有效,但是在视图上使用时出现此错误代码。

  

Msg 4405,第16级,状态1,第4行
  视图或函数“ CTE”不可更新,因为修改会影响多个基表。

0 个答案:

没有答案