Friday, 31 May 2013

ADD AND ALTER COLUMN IN A TABLE SCRIPT

---ALTER FOR COLUMN NAME NAME AND SIZE---

IF EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CollegeInfo' 
AND COLUMN_NAME = 'CollegeName')
BEGIN
ALTER TABLE CollegeInfo ALTER COLUMN  CollegeName VARCHAR(200) NOT NULL
END

------ADD FOR COLUMN -------


IF NOT EXISTS( SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'CollegeInfo' 
 AND COLUMN_NAME = 'CollegeName')
BEGIN
ALTER TABLE CollegeInfo ADD COLUMN  CollegeName VARCHAR(200) NOT NULL
END

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home