/****** Script for SelectTopNRows command from SSMS ******/
select * from (
SELECT [Id]
,[AuditType]
,[AuditStepName]
,[AuditDocumentNo]
,[AudiDataCreatedBy]
,[AudiDataCreatedDate]
,[Auditusernam]
,[AuditStatus]
FROM [ZhiDuoTong_Factory].[dbo].[vAuditData]
union
SELECT [Id]
,[AuditType]
,[AuditStepName]
,[AuditDocumentNo]
,[AuditDataCreateBy]
,[AuditDataCreateDate]
,[Audituserman]
,[AuditStatus]
FROM [ZhiDuoTong_Factory].[dbo].[vHasAuditData]
)
显示结果:
消息 102,级别 15,状态 1,第 25 行
')' 附近有语法错误。
正确的写法:
create view vAuditAllRecords
as
(
select * from (
SELECT [Id]
,[AuditType]
,[AuditStepName]
,[AuditDocumentNo]
,[AudiDataCreatedBy]
,[AudiDataCreatedDate]
,[Auditusernam]
,[AuditStatus]
FROM [ZhiDuoTong_Factory].[dbo].[vAuditData]
union
SELECT [Id]
,[AuditType]
,[AuditStepName]
,[AuditDocumentNo]
,[AuditDataCreateBy]
,[AuditDataCreateDate]
,[Audituserman]
,[AuditStatus]
FROM [ZhiDuoTong_Factory].[dbo].[vHasAuditData]
)
AllRecords
)