Home > Database > Mysql Tutorial > 表变量,代替临时表

表变量,代替临时表

WBOY
Release: 2016-06-07 14:56:39
Original
1258 people have browsed it

一个跟临时表差不多的变量 无 declare @t table(id int identity,col varchar(4))declare @sql varchar(60)set @sql='吕布赵云马超典韦关羽张飞许褚黄忠颜良文丑庞德孙策'declare @i int;set @i=1declare @n int;set @n=2 --定义分段长度while(@ilen(@sql))be

一个跟临时表差不多的变量
declare @t table(id int identity,col varchar(4))

declare @sql varchar(60)

set @sql='吕布赵云马超典韦关羽张飞许褚黄忠颜良文丑庞德孙策'

declare @i int;set @i=1

declare @n int;set @n=2 --定义分段长度

while(@i<len(@sql))

begin

    insert into @t select substring(@sql,@i,@n)

    set @i=@i+@n
end

select * from @t
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template