在存储过程中给一个变量赋值的语句是select @goodsname=(select goodsname from T_Goods where goodscode=@goodscode)
但现在我想实用给两个变量赋值,语句却不能这样写:select @goodsname,@other=(select goodsname,other from T_Goods where goodscode=@goodscode)
我又不想分成两条语句来写,因为数据集打开关上我担心会影响速度.请问这样的语句该怎么写?
但现在我想实用给两个变量赋值,语句却不能这样写:select @goodsname,@other=(select goodsname,other from T_Goods where goodscode=@goodscode)
我又不想分成两条语句来写,因为数据集打开关上我担心会影响速度.请问这样的语句该怎么写?
解决方案 »
- 怎样判断两个ihtmlelement指针是相同的指针?
- 求画布一个简单图象方法,高人指导,在线等!
- 求助Delphi编程
- 100分 求一个方案 局域网中客户端上Delphi将文件上传到服务器,并且能下载
- ListView的行高问题
- 进来看看,来者有分!!!!!!!!!!!!!!!!!
- delphi中调用外部程序(ShellExecute)为什么老说没有定义呀,各位帮忙解释一下!
- 如何把一个窗体放到屏幕的绝对最上面,是绝对的。
- 求csdn工具?
- idsmtp发送邮件时如何显示进度
- 请问:拖放中被接收对象事件里的鼠标的坐标如何转换到被接收对象的相对坐标?
- 刚用delphi,请各位多多帮忙。。。(在线等)
set @goodsname = @other
@goodsname,@other是两个不同的变量,要从两个不同的字段取值.你这样做这两个变量的值不是一样了吗?
昨天我后来又遇到一个问题,关于in语句的.
比如select Goodscode from T_Goods where GoodsCode in('001','002') 这样是可以的.
而我把edit的text值为'001','002'作为参数传递进去就不行.Why?
上面人不是说清楚了吗
set @sqL='select Goodscode from T_Goods where GoodsCode in (' + @P + ')'
execute(@SQL)
还有人能解答吗?
select Goodscode from T_Goods where Charindex(GoodsCode, @P)>0
fancylee(小恐龙)
declare @SQL varchar(8000)
set @sqL='select Goodscode from T_Goods where GoodsCode in (' + @P + ')'
execute(@SQL)
==============================================
这个方法是可以的,因为你要传一个字符串进去,只能用这种方法把它解释成SQL语句,这也是一种常用的方法,不过注意你传进的参数@P必须如'001','002'中间的“,“不能少,引号就看你传的是什么类型,字符串就要,其它的看着办
呵呵!如您所说,是我写错了
insert into t select '001',1
union select '002',2
union select '003',3--动态sql测试
declare @s varchar(40),@sql varchar(400)
set @s = '001,002'
set @sql='select * from t where charindex(a,'''+@s+''')>0'
print @sql
exec (@sql)--结果
a b
-------------------- -----------
001 1
002 2--存储过程测试
create proc p_t(@s varchar(40))
as
begin
declare @sql varchar(400)
set @sql='select * from t where charindex(a,'''+@s+''')>0'
exec (@sql)
end
exec p_t '001,002'
--结果
a b
-------------------- -----------
001 1
002 2(所影响的行数为 2 行)