海纳百川,有容乃大
善于总结,积累软财富
【问题】用SQL 语句判断表中是否存在password字段,不存在则新增字段,若存在password字段,把字段的类型由int 类型改为text类型。

【实现方法】
if exists( select name from syscolumns  where  id=object_id('tb_userinfo') and name='password')  
  begin    
   alter table tb_userinfo  alter column [password] varchar(50)--先把int转化为varchar
   alter table tb_userinfo  alter column [password] text--再把varchar转化为text
    print 'Had upate Email Colums!'
  end
else
 begin
    ALTER TABLE tb_userinfo ADD [password] int  NULL
    print 'Had Add colums!'
 end
posted on 2006-11-15 11:48  海纳百川  阅读(1235)  评论(0编辑  收藏  举报

首页原创.NET区 div1
.NET新手区 div2
精华区 div3
专家区 div4
读书心得区 div5
百度主题实验室
百度主题推广 div7

-->