我想知道可以在SQL Server Management Studio工具中创建SCHEMABINDING视图。
我已尝试按下面的代码创建视图但我收到此错误:
无法对视图'test2'进行架构绑定,因为名称'tb_CT_CS_transmittalNo'对于架构绑定无效。名称必须采用两部分格式,对象不能引用自身。
创建视图的代码如下所示:
CREATE VIEW test2
WITH SCHEMABINDING
AS
SELECT
d.[Project No], d.Originator, d.Zone, d.Unit, d.Discipline,
dis.DiscDesc, d.[Document Type], d.[Owner Document Number], d.[Sazeh
Document Number],
d.[IDENTIFICATION CODE1], d.[IDENTIFICATION CODE2], d.[Document Title],
d.SheetNumber, charindex('(', t.[Owner Document Number]) - 1 AS Doc_Visual_pos,
IIF(charindex('(', t.[Owner Document Number]) - 1 > 0, LEFT(t.[Owner Document Number], charindex('(', t.[Owner Document Number]) - 1), t.[Owner Document Number]) AS Doc_Visual,
t.REV, t.POI, p.[Purpose of Issue Description],
t.CC, t.[Int-Tr-NO], t.[To-Owner-Tr-No], t.[MC-CSheet-No], t.AcCode,
t.Pages, t.PaperSize, t.SJC_TO_MC_Let_NO, t.MC_TO_SJC_Let_No,
t.To_FEng_Tr_No, t.SJC_Tr_No, t.Ext_Int, t.[Early Planned Issue Date],
t.[Late Planned Issue Date], t.[Tag-No], t.Phase, t.SubPhase,
t.ActivityID, t.Manhour, t.WorkPackage, t.[DCN-No], t.[DCR-No],
t.[DCR-Reason], t.Remark, t.LastRevPerDoc, t.LastRevPerPOI,
t.HoldBy, t.CommentID, t.ExTrID, t.HT_TR_No, t.Recipients,
t.MC_HD_Comment_No, t.[CT-Transmittals], ct.[CT_CS_Tr-Date],
t.DefaultForDocument, t.HyperDoc, t.root
FROM
tb_CT_CS_transmittalNo AS ct
RIGHT JOIN
(((tblDocuments AS d
LEFT JOIN
tblTransmittals AS t ON d.[Owner Document Number] = t.[Owner Document Number])
LEFT JOIN
tblPurposeofIssue AS p ON t.POI = p.[Purpose of Issue])
LEFT JOIN
tblDiscipline AS dis ON d.Discipline = dis.DiscCode) ON ct.CT_CS_Tr_No = t.[CT- Transmittals];