ADO.NET - How To: Rename a Column
Here is an example of renaming an existing column of a table in a Microsoft SQL Server database:
1 min read27 words1 code sample
Introduction#
Here is an illustration of how to change the name of an existing column in a Microsoft SQL Server table:
C#
private void btnDatabase_Click(object sender, EventArgs e)
{
string strConnection = "sp_rename 'StaffMembers.FullName',
'EmployeeName', 'COLUMN';";
SqlConnection conDatabase = new
SqlConnection("Data Source=(local);" +
"Database='Countries2';" +
"Integrated Security=yes");
SqlCommand cmdDatabase = new SqlCommand(strConnection, conDatabase);
conDatabase.Open();
cmdDatabase.ExecuteNonQuery();
conDatabase.Close();
}Home Copyright © 2011 C# Key

