当前位置: 代码迷 >> Sql Server >> 返回的是一句执行语句 要看到试图应该如何写
  详细解决方案

返回的是一句执行语句 要看到试图应该如何写

热度:52   发布时间:2016-04-27 14:10:16.0
返回的是一句执行语句 要看到试图应该怎么写?
drop procedure cit_namee
create procedure cit_namee
as begin 
declare @_i int
declare @_len int
declare @s varchar(1000)
declare @b varchar(2)
set @b=1
set @s='select '
select @_len=max(len(cityname)) from dbo.T_city 
set @_i=1 
while @_i <= @_len
begin
set @s = @s + ' substring(cityname , ' + ltrim(@_i) + ',[email protected]+' ) as 第'+ltrim(@_i) +'个字节 ,'
-- select substring(cityname, @_i,1) from dbo.T_city 
set @_i=@_i+1
end
set @s = substring(@s , 1 , len(@s) - 1) + ' from dbo.T_city'
print @s
end 
exec cit_namee 
返回的是一句执行语句 要看到试图应该怎么写?

------解决方案--------------------
SQL code
drop procedure cit_nameecreate procedure cit_nameeas begin  declare @_i intdeclare @_len intdeclare @s varchar(1000)declare @b varchar(2)set @b=1set @s='select 'select @_len=max(len(cityname)) from dbo.T_city  set @_i=1  while @_i <= @_lenbeginset @s = @s + ' substring(cityname , ' + ltrim(@_i) + ',[email protected]+' ) as 第'+ltrim(@_i) +'个字节 ,'-- select substring(cityname, @_i,1) from dbo.T_city  set @_i=@_i+1endset @s = substring(@s , 1 , len(@s) - 1) + ' from dbo.T_city'--print @sexec (@s)end  go
  相关解决方案