G
gtln
Unregistered / Unconfirmed
GUEST, unregistred user!
我要执行以下SQL语句,用的是ADOCommand,提示不能完成,请教好的方法
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Report01]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[Report01]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Report02]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[Report02]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.Report01
AS
SELECT DepID, DepCode, DepName, ISNULL(Depbudget, 0) AS Depbudget, ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe01, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe02, ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe03,
ISNULL(Depbudget - ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0), 0) AS Exe04, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) + ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe05
FROM dbo.DepInf
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.Report02
AS
SELECT TOP 100 PERCENT DepId, ItemName, ISNULL(ItemBudget, 0) AS ItemBudget,
AccId, ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe01, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe02, ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe03,
(SELECT DepName
FROM DepInf
WHERE DepId = ItemBudget.DepId) AS DepName,
(SELECT AccName
FROM AccInf
WHERE AccId = ItemBudget.AccId) AS AccName,
ISNULL(ItemBudget - ISNULL
((SELECT SUM(Exe01)
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0), 0) AS Exe04, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) + ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe05
FROM dbo.ItemBudget
ORDER BY DepName
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Report01]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[Report01]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Report02]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[Report02]
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.Report01
AS
SELECT DepID, DepCode, DepName, ISNULL(Depbudget, 0) AS Depbudget, ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe01, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe02, ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe03,
ISNULL(Depbudget - ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0), 0) AS Exe04, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) + ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE DepID = dbo.DepInf.DepID), 0) AS Exe05
FROM dbo.DepInf
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.Report02
AS
SELECT TOP 100 PERCENT DepId, ItemName, ISNULL(ItemBudget, 0) AS ItemBudget,
AccId, ISNULL
((SELECT SUM(Exe01) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe01, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe02, ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe03,
(SELECT DepName
FROM DepInf
WHERE DepId = ItemBudget.DepId) AS DepName,
(SELECT AccName
FROM AccInf
WHERE AccId = ItemBudget.AccId) AS AccName,
ISNULL(ItemBudget - ISNULL
((SELECT SUM(Exe01)
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0), 0) AS Exe04, ISNULL
((SELECT SUM(Exe02) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) + ISNULL
((SELECT SUM(Exe03) AS Exe01
FROM ItemExe
WHERE ItemID = ItemBudget.ItemID), 0) AS Exe05
FROM dbo.ItemBudget
ORDER BY DepName
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO