Hi,
Issue a query using INFORMATION_SCHEMA.COLUMNS. For example, to get a
DataSet containing the column information of a table named, "YourTable" that
meet your specific requirements:
DataSet data = new DataSet();
using (SqlConnection conn = new SqlConnection(connString))
{
using (SqlDataAdapter adapter = new SqlDataAdapter(
@"SELECT * FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = N'YourTable'
AND DATA_TYPE = N'nvarchar'
AND CHARACTER_MAXIMUM_LENGTH = 5", conn))
{
adapter.Fill(data);
}
// TODO: alter table
}
You can issue an ALTER TABLE T-SQL statement to perform the modification.
An alternative to this is SMO:
"Sql Server Management Objects"
http://msdn2.microsoft.com/en-us/library/ms162169.aspx