可以在存储过程中进行条件判断吗
有一个存储过程:
create procedure chaxunproc
@name varchar(50), //对应字段名
@contents varchar(50) //对应查询内容
as
declare @s1 varchar(200)
set @sl='select * from table where '+@name+'like'''+@contents+''''//这一句这样写对不对?
exec @sl
if exists(@s1) 判断查询的内容是否存在。同时请问这样写法是否正确?
print 'ok' //如果找到,显示OK。其实我想在这一句去改变dbgrid或STRINGGRID查找到的记录的颜色,可不可以?
else
print 'no find'
在DELPHI中调用adostoredproc1
with adostoredproc1 do
begin
parameters[0].value:=combobox1.text;
parameters[1].value:=edit1.text;
parameters.ParamByName('@name').asstring:=combox1.text;
parameters.ParamByName('@contents').asstring:=edit1.text;
open;
end;