分享

sql server 中升级数据库 如没有表,表中没有字段需要升级

 水中麒麟 2014-02-25
if(rest->State == adStateOpen)
{
rest->Close();
}
 
sql语句:
sql = “select * from sysobject where name = 'newTable'”;
rest->open(......)
if(rest->adoEOF())
{
// 新建表的sql
sql = 。。。
try
{
pCommand->Execute();
}
catch(_com_error &e)
{
 
}
 
}
 
2、升级表
if(rest->State == adStateOpen)
{
rest->Close();
}
 
sql = “select * from syscolumns where id = object_id('table name ') and name ='columnname'”;
try{
rest->open(sql,,,,,,,);
}
catch(_com_error &e)
{
rest->close();
conn->close();
}
 
if(rest->adoEOF)
{
sql = "alter table tablename add newColumns not null";
pCommand->CommandText = sql;
try
{
pCommand->Execute();
}
catch(_com_error &e)
{
 
}
}
 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约