2
I ran the following script:
CREATE TABLE [dbo].[horario](
[Ano] [int] NOT NULL,
[CodigoTurma] [varchar](5) NOT NULL,
[Ordem] [int] NOT NULL,
[Professor_Id] [int] NOT NULL,
[Matriz_Semestre] [int] NOT NULL,
[Matriz_Curso_Codigo] [varchar](5) NOT NULL,
[Matriz_Disciplina_Codigo] [varchar](5) NOT NULL,
CONSTRAINT [primary key1] PRIMARY KEY CLUSTERED
(
[Ano] ASC,
[Professor_Id] ASC,
[Matriz_Semestre] ASC,
[Matriz_Curso_Codigo] ASC,
[Matriz_Disciplina_Codigo] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
I cannot remove the created table, so to add a new column surround the following command:
ALTER TABLE horario ADD Dia [int] NOT NULL
The problem is that I need this new column to also be part of the set primary key
. Can someone help me?
For some reason the bank was like this:
You as always being feral @Gypsy, thank you very much my friend. But unfortunately returned a error:
'key1' is not a constraint.
, but I don’t understand why...– Jedaias Rodrigues
In the
DROP
or in theADD
?– Leonel Sanches da Silva
the
Drop
......– Jedaias Rodrigues
Check the key name if it is
key1
even.– Leonel Sanches da Silva
Well, in the script is exactly key1 even, but there is some way to be checked in the bank itself with some command?
– Jedaias Rodrigues
@Jedaiasrodrigues I updated the answer.
– Leonel Sanches da Silva
I updated the question...
– Jedaias Rodrigues
@Jedaiasrodrigues The previous query only gave the name of the columns, so I put another query that may be more useful.
– Leonel Sanches da Silva
The result was
CONSTRAINT_NAME = primary key1
updated the question...– Jedaias Rodrigues
I discovered, just use: [Primary key1] with brackets in the name!
– Jedaias Rodrigues