去掉* 后,就不报错:向变量赋值的 SELECT 语句不能与数据检索操作结合使用
本身xtm00表就一行一个字段,
declare @ls_srqh char(10);--生日券号
SELECT TOP 1 @ls_srqh=CAST(cast(ceiling(rand() * 10000000000) as decimal(18,0)) as CHAR(10))
--加上,* 就报错:向变量赋值的 SELECT 语句不能与数据检索操作结合使用
FROM xtm00
select @ls_srqh FROM xtm00
select right('0000000000'+@ls_srqh,10) FROM xtm00
下面的就不报错:
declare @ls_srqh char(10);--生日券号
SELECT TOP 1 @ls_srqh=CAST(cast(ceiling(rand() * 10000000000) as decimal(18,0)) as CHAR(10))
FROM xtm00
select @ls_srqh FROM xtm00
select right('0000000000'+@ls_srqh,10) FROM xtm00