Your problem looks like what you need to solve using T-SQL, not C #, unless there is some kind of business rule that you select dynamically and calculate the column values. T-SQL should be a way. Just write a stored procedure or just open a management studio and write a code to make changes.
If this does not help, please clarify what exactly you want to do in the table, then we can help you figure out whether it can be done through T-SQL or not.
[EDIT] you can do something like this
string sql = " USE " + paramDbName; sql+= " ALTER TABLE XYZ ADD COLUMN " + param1 + " datatype etc, then put semicolon to separate the commands as well" sql+= " UPDATE XYZ SET Columnx = " + some logic here cmd.CommandText = sql; cmd.ExecuteNonQuery();
Run this on the right instance of Sql Server 2008.
If you have too many lines of text, use StringBuilder.
source share