Introduction:
In this article I will explain how to change or rename datatype of column in SQL server.
In this article I will explain how to change or rename datatype of column in SQL server.
Description:
In
previous post I explained how to alter or modify or delete or change already existing column
in datatable in SQL Server and many articles relating to SQL
Server.
Now I will explain how to rename or change datatype of column name or table
name in SQL Server.
Syntax
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. |
|||
|
|||
3 comments :
Does this work even if the column is populated with data? I dont think so. The right way to do this is to create a new aux column, copy the original data there, empty the target column with nulls, alter it, and the copy back data from aux to target.
hai suresh, what is the different between nvarchar and varchar?
@Edi Prakoso....
check this post
http://www.aspdotnet-suresh.com/2012/07/difference-between-char-varchar-and.html
Note: Only a member of this blog may post a comment.