Earlier solutions don't really address using sp_rename specifically...
sp_rename has these parameters objname,newname,objtype
To rename a column use:
Dim sTable as string = "myTable"
Dim sOldFieldName as string= "FieldToRename"
Dim sNewFieldName as string= "NewFieldName"
Dim params As New Generic.List(Of system.Data.SqlClient.SqlParameter)
params.Add(New system.Data.SqlClient.SqlParameter("objname", sTable+"."+sOldFieldName))
params.Add(New system.Data.SqlClient.SqlParameter("newname", sNewFieldName))
params.Add(New system.Data.SqlClient.SqlParameter("objtype", "COLUMN"))
ExecDataParamsList("EXEC sp_rename @objname, @newname, @objtype",params)
--
function ExecDataParamsList(ByVal sql As String, parameters As Generic.List(Of Data.SqlClient.SqlParameter))
Using mConnection As SqlClient.SqlConnection = New SqlConnection(GetConnectionString)
mConnection.Open()
Using cmd As SqlCommand = New SqlCommand(sql, mConnection)
cmd.CommandType = CommandType.Text
Cmd.Parameters.AddRange(parameters.ToArray)
cmd.CommandText = sql
cmd.ExecuteNonQuery()
Cmd.Parameters.Clear()
End Using
End Using
End function
This will prevent the "Could not find Stored Procedure sp_rename" error