I have to alter the table Statistic
when I add a new metric in the table Metric
I add a column in table Statistic
.
I used a stored procedure that allows me to alter the table Statistic
so the code :
CREATE PROCEDURE dbo.addnewmetricInstat
(
@MetricName varchar(254),
@TypeMetric varchar(254)
)
AS
IF (@TypeMetric='int')
Begin
alter table Statistic
add @MetricName int null
end
ELSE if (@TypeMetric='string')
begin
alter table Statistic
add @MetricName varchar(254) null
end
Then I successfully called the stored procedure but the columns is not added. The code I used in C# for calling this stored procedure is:
using (DataClassesDataContext db = new DataClassesDataContext("Data Source=EMEA-TUN-WS0367\\SQLEXPRESS;Initial Catalog=Perfgas;Integrated Security=True"))
{
db.addnewmetricInstat(metric.MetricName, metric.Type);
db.SubmitChanges();
}