|
Murali
Starting Member
4 Posts |
Posted - 2001-09-04 : 01:52:58
|
| I have created following view with schema binding asCREATE VIEW SALES_ANALYSIS_BYMWITH SCHEMABINDINGAS select s.period_id, s.location_id, s.customer_id, s.rep_id, s.products_id, s.a_sale_amount, s.sale_amount, dbo.getprevmonthdata( s.period_id, s.location_id, s.products_id, s.rep_id, s.customer_id ) as prev_month_actual, dbo.getprev_year_same_month_actual( s.period_id, s.products_id, s.customer_id, s.rep_id, p.period_year ) as perv_year_same_month_actual, dbo.getactual_ytd( s.period_id, s.products_id, s.customer_id, s.rep_id, p.period_year ) as actual_ytd, dbo.getbgt_ytd( s.period_id, s.products_id, s.customer_id, s.rep_id, p.period_year ) as budgeted_ytd, dbo.getprev_year_ytd( s.period_id, s.products_id, s.customer_id, s.rep_id, p.period_year ) as prev_year_actual_ytd, c.customer_name, l.location_name, prod.product_name, p.period_name, sr.first_name+', '+sr.last_name as srep_name, pline.product_line_name, pline.product_line_id, b.brand_id, b.brand_namefrom dbo.sales_fact s, dbo.period p, dbo.products prod, dbo.sales_rep sr, dbo.customer c, dbo.location l, dbo.product_line pline, dbo.brands bwhere p.period_id = s.period_id and l.location_id = s.location_id and c.customer_id = s.customer_id and sr.rep_id = s.rep_id and prod.product_id = s.products_id and pline.product_line_id = b.product_line_id and b.brand_id = prod.brand_id View has been created successfully with out any problem thenI have tried to create index on above with following syntaxGOSET ARITHABORT ONCREATE UNIQUE CLUSTERED INDEX ivSALES_ANALYSIS_BYMON SALES_ANALYSIS_BYM(period_id,location_id,customer_id,rep_id,products_id)I have received following error when i treid to create index on SALES_ANALYSIS_BYM viewper return following message has comeServer: Msg 1956, Level 16, State 1, Line 1Index on view 'sqlchartapp.dbo.SALES_ANALYSIS_BYM' cannot be created because the view uses a nondeterministic user-defined function.i have used functions to create view which mandatoy in my casesyntax of one of the function used in above view-------------------------------CREATE function GETPREVMONTHDATA( @a_period_id int, @A_location_id int, @A_product_id int, @a_rep_id int, @a_customer_id int )returns float(2)with schemabindingASBEGIN return( select sum(a_sale_amount)from dbo.sales_fact where period_id=@A_period_id-1 and location_id=@A_location_id and products_id=@A_Product_id and Rep_id=@A_rep_id and customer_id=@a_customer_id )END----------------------------------------Is there any way to create index on above view?Murali |
|