C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Databases »

Modifying the Column Information using T_SQL Commands


Posted Date: 09 Jun 2004    Resource Type: Articles    Category: Databases
Author: K Hari PrasadMember Level: Gold    
Rating: 1 out of 5Points: 7



--To add a new column
ALTER TABLE Activity add test VARCHAR(10) NULL

--To Rename a Column
EXEC sp_rename 'TableName.[OldColumnName]', 'NewColumnName', 'COLUMN'

-- To change the datatype and NULL/NOTNULL for a particular column
ALTER TABLE TableName ALTER COLUMN ColumnName NewDataType NULL/NOTNULL

ALTER TABLE TableName ALTER COLUMN ColumnName VARCHAR(30) NULL

--To drop a column
ALTER TABLE TableName DROP COLUMN ColumnName

--To rename a table
EXEC sp_rename 'OldTableName','NewTableName'

Eg: EXEC sp_rename 'customers', 'custs'







Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to change the owner of the Objects(table,view etc) in a SQL Server Database?
Previous Resource: Time Conversion GMT to Current Time and Back
Return to Discussion Resource Index
Post New Resource
Category: Databases


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use