Created
June 25, 2018 16:19
-
-
Save adaoex/be4d4adbd81992037c9fadd5fa75dbca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Criar uma tabela para Teste | |
CREATE TABLE Table_TEST | |
( | |
Id INT IDENTITY(1,1), | |
Data DATETIME | |
); | |
-- Tentar um INSERT | |
INSERT INTO Table_TEST (Id, Data) | |
VALUES(10,GETDATE()) | |
/* Erro: Não é possível inserir um valor explícito para a coluna de identidade na | |
tabela 'Table_TEST' quando IDENTITY_INSERT está definido como OFF. */ | |
-- Habilita Insert em campo IDENTITY | |
SET IDENTITY_INSERT Table_TEST On | |
INSERT INTO Table_TEST(Id, Data) | |
VALUES(10,GETDATE()); | |
-- Desabilita Insert em campo IDENTITY | |
SET IDENTITY_INSERT Table_TEST Off | |
-- Teste | |
SELECT * FROM Table_TEST | |
DROP TABLE Table_TEST; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment