declare @center_stano varchar(300)
declare @loc_code_in varchar(20)
declare @i int
declare @tempchar varchar(200)
set @tempchar='*A'
set @i=ascii('B')
while @i<=ascii('Z')
begin
set @tempchar=@tempchar+'*,*'+char(@i)
--print @tempchar
set @i=@i+1
end
set @tempchar=@tempchar+'*'
set @center_stano=@tempchar
set @loc_code_in='a'
if (charindex(upper('*'+@loc_code_in+'*'),@center_stano)>0)
begin
set @center_stano=@center_stano
print '是中心代码'
end else begin
set @center_stano=@loc_code_in
end
print @center_stano
本文介绍了一段SQL脚本,该脚本演示了如何使用SQL进行字符串的拼接、ASCII值转换及条件判断等操作。通过对字符进行循环处理并构建特定格式的字符串,展示了SQL在处理文本数据方面的灵活性。
1万+

被折叠的 条评论
为什么被折叠?



