Ir para conteúdo
Fórum Script Brasil
  • 0

erro ao criar função de particionamento


EMSO.EXE

Pergunta

Ao criar uma função de particionamento o Microsoft SQL Server Management Studio (2008 R2) acusa que o objeto já existe no banco.

Mensagem de erro: There is already an object named 'PF_HISTORICOVENDA' in the database

-- SELECIONAR BANCO DE DADOS
USE [dbXPTO]
GO

-- CRIAR FILEGROUPS
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1985
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1986
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1987
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1988
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1989
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1990
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1991
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1992
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1993
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1994
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1995
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1996
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1997
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1998
ALTER DATABASE dbXPTO ADD FILEGROUP FGP1999
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2000
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2001
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2002
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2003
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2004
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2005
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2006
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2007
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2008
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2009
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2010
ALTER DATABASE dbXPTO ADD FILEGROUP FGP2011

-- CRIAR ARQUIVOS DE DADOS RELACIONANDO AOS GRUPOS
USE [master]
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1985', 
FILENAME = 'C:\db\F1985.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1985
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1986', 
FILENAME = 'C:\db\F1986.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1986
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1987', 
FILENAME = 'C:\db\F1987.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1987
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1988', 
FILENAME = 'C:\db\F1988.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1988
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1989', 
FILENAME = 'C:\db\F1989.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1989
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1990', 
FILENAME = 'C:\db\F1990.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1990
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1991', 
FILENAME = 'C:\db\F1991.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1991
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1992', 
FILENAME = 'C:\db\F1992.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1992
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1993', 
FILENAME = 'C:\db\F1993.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1993
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1994', 
FILENAME = 'C:\db\F1994.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1994
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1995', 
FILENAME = 'C:\db\F1995.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1995
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1996', 
FILENAME = 'C:\db\F1996.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1996
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1997', 
FILENAME = 'C:\db\F1997.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1997
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1998', 
FILENAME = 'C:\db\F1998.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1998
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F1999', 
FILENAME = 'C:\db\F1999.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP1999
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2000', 
FILENAME = 'C:\db\F2000.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2000
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2001', 
FILENAME = 'C:\db\F2001.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2001
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2002', 
FILENAME = 'C:\db\F2002.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2002
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2003', 
FILENAME = 'C:\db\F2003.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2003
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2004', 
FILENAME = 'C:\db\F2004.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2004
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2005', 
FILENAME = 'C:\db\F2005.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2005
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2006', 
FILENAME = 'C:\db\F2006.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2006
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2007', 
FILENAME = 'C:\db\F2007.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2007
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2008', 
FILENAME = 'C:\db\F2008.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2008
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2009', 
FILENAME = 'C:\db\F2009.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2009
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2010', 
FILENAME = 'C:\db\F2010.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2010
GO

ALTER DATABASE dbXPTO ADD FILE ( NAME = 'F2011', 
FILENAME = 'C:\db\F2011.ndf' , SIZE = 2048KB , FILEGROWTH = 1024KB ) 
TO FILEGROUP FGP2011
GO

-- CRIACAO DA FUNCAO DE PARTICIONAMENTO ---------------------------------- AQUI OCORRE O ERRO ------------------------------
CREATE PARTITION FUNCTION PF_HISTORICOVENDA (DATETIME) AS
RANGE LEFT FOR VALUES (
'1985-01-01','1986-01-01','1987-01-01','1988-01-01','1989-01-01',
'1990-01-01','1991-01-01','1992-01-01','1993-01-01','1994-01-01',
'1995-01-01','1996-01-01','1997-01-01','1998-01-01','1999-01-01',
'2000-01-01','2001-01-01','2002-01-01','2003-01-01','2004-01-01',
'2005-01-01','2006-01-01','2007-01-01','2008-01-01','2009-01-01',
'2010-01-01','2011-01-01'
)
------------------------------------------------------------------------------------------- AQUI OCORRE O ERRO ------------------------------

CREATE PARTITION SCHEME SCHEMA_VENDA AS
PARTITION PF_HISTORICOVENDA TO (FGP1985,FGP1986,FGP1987,FGP1988,FGP1989,FGP1990,
FGP1991,FGP1992,FGP1993,FGP1994,FGP1995,FGP1996,FGP1997,FGP1998,FGP1999,FGP2000,
FGP2001,FGP2002,FGP2003,FGP2004,FGP2005,FGP2006,FGP2007,FGP2008,FGP2009,FGP2010,
FGP2011)

-- EXCLUINDO INDICE CLUSTERED
ALTER TABLE VENDA DROP CONSTRAINT PK_VENDA

-- CRIANDO INDICE CLUSTERED
ALTER TABLE VENDA
ADD CONSTRAINT PK_VENDA PRIMARY KEY CLUSTERED (CD_VENDA, DT_VENDA) ON SCHEMA_VENDA(DT_VENDA)

Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,3k
    • Posts
      652,3k
×
×
  • Criar Novo...