Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Query to change column name or table name in sql server

Sep 4, 2010
Introduction:

In this article I will explain how to change or rename column name or table name in SQL server.

Description:

In previous posts I explained many articles relating to SQL Server. Now I will explain how to rename or change column name or table name in SQL Server. 

Syntax to Change existing column name in data table


SP_RENAME 'TableName.[OldColumnName]' , '[NewColumnName]', 'COLUMN'
Ex:


SP_RENAME 'UserInformation.[UserDetail]' , '[UserName]', 'COLUMN'
From the above query declaration I am changing the name of column UserDetail to UserName in table UserInformation.  

Syntax to Change table name


SP_RENAME '[OldTableName]' , '[NewTableName]'
Ex:


SP_RENAME '[UserDetails]' , '[UserInformation]'
From the above query declaration I am changing UserDetails table name to UserInformation

By using above statements we can rename existing table in database or we can rename existing Column in table.

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.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

1 comments :

Anonymous said...

not much explaination

Give your Valuable Comments

Other Related Posts

© 2010-2012 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.