Introduction:
Here I will explain how to drop column in SQL Server or delete columns from table in SQL Server 2008.
Description:
In
previous articles SQL Query to get list of tables in database, SQL add auto increment column to table, SQL Server ACID properties, SQL date diff function example and many articles related to SQL
Server. Now I will explain how to drop or delete columns from table SQL
Server.
Query
to Drop or delete column from existing table
If
we want to drop column from existing table that syntax will be like this
ALTER
TABLE Table_Name DROP
COLUMN COLUMN_NAME
|
Ex:
ALTER
TABLE emp_table DROP
COLUMN Manager_Name
|
From
the above query declaration column “Manager_Name” will drop from emp_table
Query
to modify existing column datatype in table
If
we want to modify existing column datatype from data table that syntax will be
like this
ALTER
TABLE Table_Name ALTER
COLUMN COLUMN_NAME DATATYPE
|
Ex:
ALTER
TABLE emp_table ALTER
COLUMN Manager_Name nvarchar(max)
|
From
the above query declaration I changed “Manager_Name” column datatype
from VARCHAR(50) to nvarchar(max)
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
1 comments :
kindly post an article for Collections in .net.
Note: Only a member of this blog may post a comment.