我写了这样的语句
set @value=(select top @count-@index+1 bdamount from bomdetail where bmid=@product and mciid not in (select top @count-@index mciid from bomdetail where bmid=@product))
--保留路径的分叉点的数据环境
那些变量我都声明过 且都赋了值 但是同不过语法检查 为什么呢?
...全文
1664打赏收藏
在存储过程中使用top
我写了这样的语句 set @value=(select top @count-@index+1 bdamount from bomdetail where bmid=@product and mciid not in (select top @count-@index mciid from bomdetail where bmid=@product)) --保留路径的分叉点的数据环境 那些变量我都声明过 且都赋了值 但是同不过语法检查 为什么呢?
恩 好了
现在我是这样写了
declare strsql varchar(2000)
declare @value varchar(100)
set @strsql="select top " +str(@count-@index+1) +" bdamount from bomdetail where bmid=" + @product +" and mciid not in (select top " + str(@count-@index)+" mciid from bomdetail where bmid=" +@product +"))"
下面我想把检索出的 那一条bdamount数据 赋值给另一个变量@value 怎么办呢?
我市这样写的, 但是有语法错误 ?
set @value=exec (@strsql)