谁能给我关于如何将列值转换为变量的任何想法。例如 -
声明 TD int; 声明 Cnew Varchar(10);
SET @a = Concat('Select Count(*) into ', TD, 'From tb1 where C1 =', Cnew, ';');
如何将计数(*)带入 TD????
提前致谢。
谁能给我关于如何将列值转换为变量的任何想法。例如 -
声明 TD int; 声明 Cnew Varchar(10);
SET @a = Concat('Select Count(*) into ', TD, 'From tb1 where C1 =', Cnew, ';');
如何将计数(*)带入 TD????
提前致谢。
我猜你想要这个:
Declare @TD int;
Declare @Cnew Varchar(10);
set @CNew = 'Some string'; -- or maybe this is a param passed to the sp
set @TD = (Select count(*) from tb1 where c1 like @cnew);
将给出 TD 中的实际计数,而不是 stmt。我认为您不需要为此准备好stmt。
试试这个
set @TD = 0 ;
SET @a = Concat('Select Count(*) into @td From tb1 Where C1 =', Cnew, ';');
它会做