SQL Server 变量定义

declare @id int
declare @name char(10) --注意:char(10)为10位,要是位数小了会让数据出错
set @id=1
set @name='sssss'
select @id valu,@name nam

SQL Server 变量定义

下面是我同事的一个情况, 要把一堆字符里面的表都给粘出来, 里面用到了变量的定义

declare @str varchar(max) ='jgguf${wlsld2}  dhslsla${wlsld3}dhsl

sla${wlsld5}dh

dlsla${wlsgsld6} dlsla${wslsld7} dsgdlsla '

select value from string_split(replace(@str, ' ', '#'), '$')

--{wlsld2}dhslsla

select substring(k.value2, 1, k.len1) as value3 from

(select substring(value, 2, charindex('}', value)) as value2,

len(substring(value, 2, charindex('}', value))) - 2 as len1 from string_split(replace(@str, ' ', '#'), '$')

) as k

where k.len1 > 0

go

SQL Server 变量定义

上一篇:How To Use Git Source Control with Xcode in iOS 6


下一篇:编译安装 logstash-output-jdbc