24秒

全力以赴争取每个24秒……

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: :: 订阅 订阅 :: 管理 ::

一、SQL语句 修改字段默认值的
1。 建约束

alter   table  tb_name  add   constraint   dd   default   'bbbb '   for   column_name
2。删除约束
alter   table   tb_name  drop   constraint   dd
3。重新建约束
alter   table   tb_name  add  constraint   dd   default   'cccc '   for   column_name

二、内容替换 replace

update [swf_Content] set [Description] =replace([Description],'200901/14','200901/15')
update [swf_Content_01] set [content] = replace(convert(varchar(4000), [content]),'200901/14','200901/15') --ntext类型字段转换为varchar

三、添加列并设置默认值

ALTER TABLE TBProduct ADD Discount INT NULL CONSTRAINT TBProduct_Discount_Default DEFAULT 0 WITH VALUES

四、查询表结构(一)

1.Select

col.[name]  as '字段名',

col.[length]as '长度',

type.[name] as '类型' ,

pro.value   as '描述'

From syscolumns as col

Left Join systypes as type on col.xtype = type.xtype

Left Join sysProperties as pro on col.id = pro.id and col.colid = pro.smallid

where col.id = (Select id From Sysobjects Where name = 'trole') 

 

  2.select name from syscolumns where id =(select id from sysobjects where name='trole') order by colorder 

五、修改字段类型

  ALTER TABLE tbBODetail ALTER COLUMN total MONEY NULL

posted on 2010-06-23 14:22  bignjl  阅读(191)  评论(0编辑  收藏  举报