view. red text throws error
Server: Msg 8668, Level 16, State 1, Line 1
An index cannot be created on the view 'order_balance' because the select list of the view contains a non-aggregate expression.
table structure
can this be done, or am I missing something?
Jason Meckley
Programmer
Specialty Bakers, Inc.
Server: Msg 8668, Level 16, State 1, Line 1
An index cannot be created on the view 'order_balance' because the select list of the view contains a non-aggregate expression.
Code:
IF sessionproperty('ARITHABORT') = 0 SET ARITHABORT ON
IF sessionproperty('CONCAT_NULL_YIELDS_NULL') = 0 SET CONCAT_NULL_YIELDS_NULL ON
IF sessionproperty('QUOTED_IDENTIFIER') = 0 SET QUOTED_IDENTIFIER ON
IF sessionproperty('ANSI_NULLS') = 0 SET ANSI_NULLS ON
IF sessionproperty('ANSI_PADDING') = 0 SET ANSI_PADDING ON
IF sessionproperty('ANSI_WARNINGS') = 0 SET ANSI_WARNINGS ON
IF sessionproperty('NUMERIC_ROUNDABORT') = 1 SET NUMERIC_ROUNDABORT OFF
go
--ALTER views
alter view order_balance
WITH SCHEMABINDING as
select cast(a.apply_to_no as int) as order_number,
sum(a.amt_1 + a.amt_2) as balance,
count_big(*) as cnt
from dbo.AROPNFIL_SQL a
group by a.apply_to_no
go
[COLOR=red]create unique clustered index order_balance__order_number_ind on order_balance(order_number)[/color]
EXEC sp_spaceused 'order_balance'
GO
Code:
CREATE TABLE [AROPNFIL_SQL] (
[apply_to_no] [int] NOT NULL ,
[amt_1] [decimal](14, 2) NULL ,
[amt_2] [decimal](14, 2) NULL
[COLOR=blue] --addtional columns removed for simplicity[/color]
) ON [PRIMARY]
GO
Jason Meckley
Programmer
Specialty Bakers, Inc.