根据字符串变量返回记录的问题,至今没人解决

adaddnewlwd163 2009-03-29 02:18:52
/*
cxtj="mc='eee' and hh='sss' and kk='ff'" 这个是我发送给sql的一个字符串,
里面跟的是一组条件,我希望sql根据这写条件返回一组数据,
我在sql中写了这样一个存储过程,可是不行 谁知道该怎么写
*/
CREATE PROCEDURE arkkccx
(
@cxtj varchar(200)
)
as
DECLARE @STRING1 varchar(200)

set @string1='SELECT hh as 货号,mc as 名称,kk as 款号 from ark where ''' +@cxtj+''''
exec(@string1)
GO
...全文
145 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
claro 2009-03-29
  • 打赏
  • 举报
回复
帮顶。
sdhdy 2009-03-29
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 sdhdy 的回复:]
--楼主,这是什么语法??cxtj
nresult=SQLExec(connect_temp,"Exec arkkccx ?cxtj ",'rktj')
[/Quote]\
这个是什么? 'rktj'
存储过程写的没错了,VFP语法不是很清楚,建议到VFP版问问。
adaddnewlwd163 2009-03-29
  • 打赏
  • 举报
回复
是vfp的语句
sdhdy 2009-03-29
  • 打赏
  • 举报
回复
--楼主,这是什么语法??cxtj
nresult=SQLExec(connect_temp,"Exec arkkccx ?cxtj ",'rktj')
adaddnewlwd163 2009-03-29
  • 打赏
  • 举报
回复
怎么没人回答了
adaddnewlwd163 2009-03-29
  • 打赏
  • 举报
回复
cxtj="mc='eee' and hh='sss' and kk='ff'"
nresult=SQLExec(connect_temp,"Exec arkkccx ?cxtj ",'rktj')
If nresult <0
Wait "连接服务器错误" Windows Timeout 2
Return
ENDIF


SQL的存储过程按照这里的回复改为这样
CREATE PROCEDURE arkkccx
(
@cxtj varchar(200)
)
as
DECLARE @STRING1 varchar(200)

set @string1='SELECT hh as 货号,mc as 名称,kk as 款号 from ark where ' +@cxtj
exec(@string1)
GO
htl258_Tony 2009-03-29
  • 打赏
  • 举报
回复
你是怎么调用的
adaddnewlwd163 2009-03-29
  • 打赏
  • 举报
回复
我按你说的做了,提示错误代码 170
htl258_Tony 2009-03-29
  • 打赏
  • 举报
回复
CREATE PROCEDURE arkkccx 
(
@cxtj varchar(200)
)
as
DECLARE @STRING1 varchar(200)

set @string1='SELECT hh as 货号,mc as 名称,kk as 款号 from ark where ' +@cxtj
exec(@string1)
GO

调用:
exec arkkccx 'mc=''eee'' and hh=''sss'' and kk=''ff'''
sdhdy 2009-03-29
  • 打赏
  • 举报
回复
CREATE PROCEDURE arkkccx 
(
@cxtj varchar(200)
)
as
DECLARE @STRING1 varchar(200)

set @string1='SELECT hh as 货号,mc as 名称,kk as 款号 from ark where ' +@cxtj
exec(@string1)
GO

22,211

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧