How to change data type size with query in SQL Server


 If we need to change the data type size of a particular column then we use alter table statement.
“The ALTER TABLE statement is used for add, delete, or modify columns in an existing table.”


Syntax:-

ALTER TABLE tablename
ALTER COLUMN columnname datasize


suppose we have 

we have a login table (login) and that have three columns i.e. user_id username and pwd with some datatype size as below:-


now if we want to change the space nvarchar(50) to nvarchar(max) so we just write the below query and we can get this:-


ALTER TABLE login

ALTER COLUMN username nvarchar(max)

neeraj code solutions




How to change data type size with query in SQL Server How to change data type size with query in SQL Server Reviewed by NEERAJ SRIVASTAVA on 3:49:00 PM Rating: 5

No comments:

Powered by Blogger.