/* 整理系统数据*/ create procedure pro_clearupdata as --第一部分 整理字符串类型的数据 去除两端的空格 declare @tablename varchar(50) --表名 declare @columnname varchar(50) --列名 declare cur_find cursor for select so.name,sc.name from syscolumns sc, sysobjects so, systypes st where so.name <> 'dtproperties' and st.xtype=sc.xtype and st.name='varchar' and sc.id=so.id and so.xtype='u' --查找包含varchar类型字段的所有用户表 open cur_find fetch next from cur_find into @tablename,@columnname while @@fetch_status=0 begin --去掉字段的两端空格 exec('update '[email protected]+' set '[email protected]+'=ltrim(rtrim('[email protected]+'))') fetch next from cur_find into @tablename,@columnname end close cur_find deallocate cur_find go