none
создание индексов RRS feed

  • Вопрос

  • Привет всем!

    Подскажите плз, какие нужно создать индексы на таблицах. Привожу скрипт создания табличной функции, которая использует таблицы, где пока нет индексов:

    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    
    ALTER FUNCTION [dbo].[ubki_transpose] (@StatementID varchar(36), @rowbeg int, @rowend int, @Ref varchar(40))
    RETURNS @Result TABLE
    (StatementID varchar(36), [1] int, [2] int, [3] int, [4] int, [5] int, [6] int)
    AS
    BEGIN
        insert into @Result 
    select StatementID, [1], [2], [3], [4], [5], [6] from (
     select ranks, id, StatementID from (
      select rank() OVER (order by u.Year, u.Month, u.id asc) as ranks, u.id, u.StatementID, u.Year, u.Month, 
      rtrim(convert(varchar,COALESCE (u.Year, '')) + convert(varchar,COALESCE (u.Month, ''))) 
      as period from 
        (select y.rankd, y.id, y.StatementID, y.Year, y.Month from
          (select rank() OVER (order by t.Year, t.Month, t.id asc) as rankd, 
           t.id, t.StatementID, t.Year, t.Month from (
              select d.id, d.StatementID, d.Year, d.Month, count(1) as cnt
              from vUbkiR_R6 as d where (StatementID = CONVERT(varchar(36), @StatementID) 
               and (Reference = CONVERT(varchar(40),substring(@Ref+'                                        ',1,40))))
              group by d.id, d.StatementID, d.Year, d.Month) 
           as t) as y
      where y.rankd between @rowbeg and @rowend) as u) as j) as k
    PIVOT (max(id) for ranks in ([1], [2], [3], [4], [5], [6])) as s
    RETURN 
    END
    GO
    
    SET ANSI_NULLS OFF
    GO
    SET QUOTED_IDENTIFIER OFF
    GO

    В SQL Server я новичёк, помогите кто может плз.

    29 марта 2013 г. 12:59

Ответы

Все ответы