Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Alter table alter column Syntax
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Divers
Thread ID:
01687733
Message ID:
01687736
Vues:
46
This message has been marked as the solution to the initial question of the thread.
J'aime (1)
Hi,

Please, can you run this example in MSSMS?
CREATE TABLE #TEST (XX000 INT NOT NULL, 	C_NUM decimal (15,2) NULL DEFAULT 0)
INSERT INTO #TEST (XX000, 	C_NUM) VALUES (0,1)
INSERT INTO #TEST (XX000) VALUES (1)
INSERT INTO #TEST (XX000, 	C_NUM) VALUES (2, NULL)
SELECT * FROM #TEST
ALTER TABLE #TEST ALTER COLUMN	C_NUM decimal (20,5) not null 
MartinaJ


>>>Hi,
>>>
>>>I am testing the following Alter command (in SSMS)
>>>
>>>alter TableName Alter ColumnName numeric (12,2) not null
>>>
>>>The result I get is what I want: the column size changes, it is not null, and The Default is set to 0 (which I did not specify above).
>>>Is Default set to 0 (zero) by design because my expressing says Not Null?
>>>
>>>TIA
>>
>>If you have set DEFAULT before altering the column usually must drop the constraint, alter column and then put the constraint back.
>>I got to many errors from different versions of SQL Server when I tried to alter columns so I choose this approach.
>>Maybe different versions handle this differently but I don't risk anymore.
>
>The column had the DEFAULT set before I made the change of the column size. And I do prefer not to change the default. Do I understand correctly that the DEFAULT will stay the way it was before I change the size?
>Thank you.
"Navision is evil that needs to be erazed... to the ground"

Jabber: gorila@dione.zcu.cz
Jabber? Jabbim
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform