发布网友 发布时间:2022-04-08 04:39
共4个回答
懂视网 时间:2022-04-08 09:00
@tablename varchar(50) declare @columnname varchar(50) declare cur_table cursor for select name from sysobjects where type=‘U‘ open cur_table fetch next from cur_table into @tablename while @@fetch_status=0 begin ----------------------------------------- declare cur_column cursor for select name from syscolumns where id=Object_Id(@tablename) open cur_column fetch next from cur_column into @columnname while @@fetch_status=0 begin declare @ch varchar(50),@ch1 varchar(50),@uppertablename varchar(50) set @ch=@tablename+‘.‘+@columnname set @ch1=upper(substring(@columnname,1,1))+substring(@columnname,2,len(@columnname)-1) set @uppertablename=upper(substring(@tablename,1,1))+substring(@tablename,2,len(@tablename)-1) exec sp_rename @tablename,@uppertablename exec sp_rename @ch,@ch1,‘column‘ fetch next from cur_column into @columnname end close cur_column deallocate cur_column ----------------------------------------- fetch next from cur_table into @tablename end close cur_table deallocate cur_table执行后整个数据库的表名和字段名都会变成首字母大写的形式。
将数据库所有表和字段首字母变成大写
标签:
热心网友 时间:2022-04-08 06:08
用函数upper就可以处理了热心网友 时间:2022-04-08 07:26
UPPER(<c1>) 把字符串c1转换为大写热心网友 时间:2022-04-08 09:01
用UPPER函数