Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Multiple add commands in the same alter <table>

Author  Topic 

skiabox
Posting Yak Master

169 Posts

Posted - 2008-10-30 : 05:32:17
Can I use more than one add command in the same alter <table> command?
Thank you!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 05:35:35
you can have more than one columns after add like
ALTER TABLE tablename ADD col1 int,col2 varchar(10),...
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2008-10-30 : 05:48:06
Thank you very much, in fact after the comma I used a constraint.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 05:54:35
Can you please show us code you tried?
Go to Top of Page

skiabox
Posting Yak Master

169 Posts

Posted - 2008-10-30 : 05:58:06
Yea no problem.
Here's the code:

ALTER TABLE buildings
ADD typeName nvarchar(20) NOT NULL,
CONSTRAINT buildings_fk2 FOREIGN KEY (typeName) REFERENCES building_type
ON UPDATE CASCADE ON DELETE NO ACTION
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-30 : 06:04:52
it works for me
Go to Top of Page
   

- Advertisement -