博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
SQL SERVER 批量将修改字段名为大、小写
阅读量:7217 次
发布时间:2019-06-29

本文共 665 字,大约阅读时间需要 2 分钟。

hot3.png

varchar(300)
     declare @tablecolumnname varchar(100), @columnname varchar(100)
     declare cursor1 cursor for         
     select b.name+'.['+a.name+']',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                
     open cursor1                       
     fetch next from cursor1 into @tablecolumnname,@columnname
     while @@fetch_status=0           
     begin
         set @sql='sp_rename '''+@tablecolumnname+''','''+lower(@columnname)+''',''column''' -- 此为修改为大写,如果修改为小写“lower”
         --print @sql 
         exec(@sql)             
         fetch next from cursor1 into @tablecolumnname,@columnname
     end
     close cursor1                   
     deallocate cursor1

转载于:https://my.oschina.net/sansom/blog/123980

你可能感兴趣的文章
Java中的clone
查看>>
Lucene基础(2)
查看>>
Oracle 存储过程
查看>>
java基础 静态 static 问在多态中,子类静态方法覆盖父类静态方法时,父类引用调用的是哪个方法?...
查看>>
FlasCC发布说明
查看>>
如何在macOS Sierra中运行CORE Keygen破解程序
查看>>
终极解决方案:windows10资源管理器假死
查看>>
【java】一维数组循环位移方阵
查看>>
Essential Studio for mobile MVC中创建Razor应用程序平台教程
查看>>
java主函数的含义
查看>>
中国大学MOOC —— 学习笔记(四)
查看>>
访问,ringbtn,
查看>>
致橡树
查看>>
一段测试代码,哦哦哦,
查看>>
uiimagepickercontroller,中文,--》摘
查看>>
第四次作业
查看>>
在python中调用js或者nodejs
查看>>
【年终总结】2年计划还是要有的,万一实现了呢?(转自叶小钗)
查看>>
数字图像处理学习笔记(1.1)---位图的读写、几何变换、傅里叶变换、直方图均衡...
查看>>
javascript数组顺序-----1冒泡的另一种比较好理解的写法
查看>>