Saturday, February 25, 2012

Alter Table ,add Column ,alter Column datatype

Adding column

You can add new columns to an existing table. 

ALTER TABLE [dbo].[TableName]
ADD   NameOfNewColumn Varchar(500) NULL  

GO

Alter column

You can add modify an existing column
ALTER TABLE [dbo].[TableName]
 
ALTER COLUMN [NameOfNewColumn ]  int NULL

GO

Drop column

You can add modify an existing column
ALTER TABLE [dbo].[TableName]
Drop
[NameOfNewColumn ]  int

GO 

For more details visit msdn link

Happy Living...
Happy Concepts...
Happy Coding...

No comments:

Post a Comment