to change column data type, or making it not null etc, u can use alter table syntx like this
<div>ALTER TABLE TableName
ALTER COLUMN column_name varchar(MAX)</div> <div> </div> <div>see complete list of alter table syntax</div> <div>http://www.w3schools.com/sql/sql_alter.asp</div>
hope this helps...
Cheers!
KK
Please mark as Answer if post helps in resolving your issue
My Site
you can easily add new column in table as identity
alter table TableName
Add ColumnName int identity(1,1)
but, to alter exisiting column and making it as identity is not straightforward... since, u might have some data in existing column which does not follow identity....
Honnappa
Participant
1112 Points
534 Posts
How to rename or alter column name of the existing Table?
Feb 23, 2012 10:02 AM|LINK
Can any tell me How to rename or alter a column structure of the existing Table..
My Profile
arunabathan
Member
730 Points
236 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 10:10 AM|LINK
hi,
use ALTER Query to change the Column name in TABLE.
for ex:
ALTER TABLE table_name ALTER COLUMN column_name datatype.
also refer below links,
http://wwww.w3schools.com/sql/sql_alter.asp
http://www.techonthenet.com/sql/tables/alter_table.php
Thanks&Regards,
Arunabathan.G
Shatrughna.k...
Participant
778 Points
174 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 10:12 AM|LINK
kedarrkulkar...
All-Star
35559 Points
5698 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 10:15 AM|LINK
use this to rename column of table
SP_RENAME 'TableName.ColumnName', 'NewColumnName', 'Column'
replace TableName, ColumnName and NewColumName with proper values
http://msdn.microsoft.com/en-us/library/ms188351.aspx
to change column data type, or making it not null etc, u can use alter table syntx like this
<div>ALTER TABLE TableNameALTER COLUMN column_name varchar(MAX)</div> <div> </div> <div>see complete list of alter table syntax</div> <div>http://www.w3schools.com/sql/sql_alter.asp</div>
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
Honnappa
Participant
1112 Points
534 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 10:17 AM|LINK
Thank you aruna....I wanna set identity property to this column .
is this ok?
But this is not working
My Profile
kedarrkulkar...
All-Star
35559 Points
5698 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 10:33 AM|LINK
you can easily add new column in table as identity
alter table TableName
Add ColumnName int identity(1,1)
but, to alter exisiting column and making it as identity is not straightforward... since, u might have some data in existing column which does not follow identity....
this article explains the details
http://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/
hope this helps...
KK
Please mark as Answer if post helps in resolving your issue
My Site
arunabathan
Member
730 Points
236 Posts
Re: How to rename or alter column name of the existing Table?
Feb 23, 2012 11:02 AM|LINK
hi,
please refer below links,
http://blog.sqlauthority.com/2009/05/03/sql-server-add-or-remove-identity-property-on-column/
http://stackoverflow.com/questions/1049210/adding-an-identity-to-an-existing-column
Thanks&Regards,
Arunabathan.G