samedi 5 juillet 2014

Microsoft SQL Server multiple constraints


Vote count:

0




I am supposed to modify my current table named MEMBER ins Microsoft SQL Server 2012.


I have come across many hardships.


One hardship that I have is trying to modify the tables



ALTER TABLE MEMBER
ADD CONSTRAINT U_MEMBERID UNIQUE(MEMBER_ID), primary key (MEMBER_ID);
ADD CONSTRAINT Sys_date DEFAULT GETDATE() FOR MEMBER_ID;


The above doesn't work and it says "Msg 156, Level 15, State 1, Line 3 Incorrect syntax near the keyword 'CONSTRAINT'."


I think I am doing something wrong, but I am not sure what it is.



ALTER TABLE TITLE
ADD CONSTRAINT U_TITLEID UNIQUE(TITLE_ID), primary key (TITLE_ID);
add constraint C_CATEGORY CHECK(CATEGORY='DRAMA' OR 'COMEDY' OR 'ACTION'
OR 'CHILD' OR 'SCIFI' OR 'DOCUMENTARY';


Also, is it possible to add the above code to the code preceding it and execute both of them in the same sql query. Also, how do I fix this check thing.


I know that there is a lot of asking in question but I need to get fully fathom this stuff for my homework.



asked 1 min ago






Aucun commentaire:

Enregistrer un commentaire