如下红色部分为什么转换老是出错,我写成定值可以,写成cast(@i as nvarchar)可以,为什么写成cast((@i-1) as nvarchar)就出错呢?
set @str = SUBSTRING(@context,6, 1);
set @i = CAST(SUBSTRING(@context,7, 1) as int);
if @i = 1
begin
set @sql=N'set @strnum = (select top 1 * from LuckyStation.dbo.f_splitstr('''+ rtrim(@win_code) + ''','',''))';
end
else
begin
set @sql=N'set @strnum = (select top ' + CAST(@i as nvarchar) + ' * from LuckyStation.dbo.f_splitstr('''+ rtrim(@win_code) + ''','','')
except
select top '+cast((@i-1) as nvarchar) +' * from LuckyStation.dbo.f_splitstr('''+ rtrim(@win_code) +''','',''))';
end
set @paraDefine = N'@strnum nvarchar(50) output';
exec sp_executesql @sql,@paraDefine,@strnum output
慕斯王
UYOU
元芳怎么了
饮歌长啸
相关分类