我試圖把這個SQL例如命令轉換爲C#SqlCommand
:C#的SqlCommand語法SQL命令
if not exists (select column_name
from INFORMATION_SCHEMA.columns
where table_name = 'TotalHeals'
and column_name = '"+Healee+"')
alter table TotalHeals add +Healee+ int
我至今
// TO DO check to see if column exists instead of throwing error
cmd2 = new SqlCommand("ALTER TABLE TotalHeals ADD " + Healee + " INT",openCon);
cmd2.ExecuteNonQuery();
我完全失去如何編碼if not exists語句。任何幫助?
我動態在飛行中添加列,並且不希望只捕獲異常時,列已經存在 –