/更改表名/

    declare @sql varchar(300)

    declare @tablename varchar(100)

    declare cursor1 cursor for

    select name from sysobjects where xtype = ‘u’ order by name

    open cursor1

    fetch next from cursor1 into @tablename

    while @@fetch_status=0

    begin

    1. set @sql='sp_rename '''+@tablename+''','''+lower(@tablename)+''''
    2. print @sql
    3. exec(@sql)
    4. fetch next from cursor1 into @tablename

    end

    close cursor1

    deallocate cursor1

    /更改字段名/

    declare @sql_ziduan varchar(300)

    declare @tablename_ziduan varchar(100), @columnname_ziduan varchar(100)

    declare cursor1_ziduan cursor for

    —select DISTINCT a.name from syscolumns a ,sysobjects b where a.id = object_id(b.name) and b.xtype = ‘u’ and a.xtype <>189 and a.xtype <>34 and a.xtype <>35 and a.xtype <>36
    select a.name,b.name from syscolumns a ,sysobjects b where a.id = object_id(b.name) and b.xtype = ‘u’ and a.xtype <>189 and a.xtype <>34 and a.xtype <>35 and a.xtype <>36

    open cursor1_ziduan

    fetch next from cursor1_ziduan into @columnname_ziduan,@tablename_ziduan

    while @@fetch_status=0

    begin

    1. set @sql_ziduan='sp_rename '+ ''''+@tablename_ziduan+'.'+@columnname_ziduan+''''+','+''''+lower(@columnname_ziduan)+''''+','+''''+'COLUMN'+''''<br /> print @sql_ziduan <br /> exec(@sql_ziduan) <br /> fetch next from cursor1_ziduan into @columnname_ziduan,@tablename_ziduan

    end

    close cursor1_ziduan

    deallocate cursor1_ziduan