IF (EXISTS(Select * from sys.systable where LCase(table_name) = LCase('v_SpaServiceList'))) THEN Drop view v_SpaServiceList END IF GO create view dba.v_SpaServiceList as select s.ServiceName, s.ServicePrice, KodCurrency=(if s.ServiceType = 1 then(select c.Symbol from dba.Currencies as c where c.KodCurrency=s.KodCurrency) else(select c.Symbol from dba.SpaCurrencies as c where c.KodCurrency=s.KodCurrency) endif), s.Active, TipSdelka=(select vs.SdelkaName from dba.VidSdelki as vs where vs.N=s.TipSdelka) from dba.Services as s where s.ServiceType=2 GO delete from Relations where TableName='v_SpaServiceList' go insert into Relations Values('v_SpaServiceList','__OPTIONS__','Спа услуги цени','__OPTIONS__','SpaServicePrice','__OPTIONS__',1,(select max(N)+10 from Relations),'__OPTIONS__','','',0,0,'','','','',80,'',0,0,'',today()); GO insert into Relations Values('v_SpaServiceList','ServiceName','Спа услуги цени','Услуга','SpaServicePrice','ServiceName',2,(select max(N)+10 from Relations),'ServiceName','','',0,1,0,0,'select ServiceName from Services where ServiceType=2','',150,'',0,0,1,today()); GO insert into Relations Values('v_SpaServiceList','ServicePrice','Спа услуги цени','Цена','SpaServicePrice','ServicePrice',2,(select max(N)+10 from Relations),'ServicePrice','','',0,0,0,0,'','',40,'',0,0,1,today()); GO insert into Relations Values('v_SpaServiceList','KodCurrency','Спа услуги цени','Валута','SpaServicePrice','KodCurrency',2,(select max(N)+10 from Relations),'KodCurrency','','',0,0,0,0,'','',35,'',0,0,1,today()); GO insert into Relations Values('v_SpaServiceList','Active','Спа услуги цени','Акт/Неакт','SpaServicePrice','Active',2,(select max(N)+10 from Relations),'Active','','',0,0,0,0,'','',45,'',0,0,1,today()); GO insert into Relations Values('v_SpaServiceList','TipSdelka','Спа услуги цени','ДДС/без ДДС','SpaServicePrice','TipSdelka',2,(select max(N)+10 from Relations),'TipSdelka','','',0,0,0,0,'','',45,'',0,0,1,today()); GO for f1 as curs1 scroll cursor for select a.N as @Num, a.Name as @GrName from AdminGroups a do for f2 as curs2 scroll cursor for select Min(r.N) as @RelationsN, r.BgTableName as @Spravka from Relations r Group By r.BgTableName do if (not Exists(Select RelationN from InformPermission where RelationN=@RelationsN and AdminGroupNo=@Num)) then Insert into InformPermission (N, RelationN, AdminGroupNo, Stoinost) values((select max(N)+1 from InformPermission ), @RelationsN, @Num, 1); end if end for end for; //Keti - syzdava spravka SPA uslugi ceni,13.06.2008