SQL存储过程获取问题 [英] Sql Stored Procedure Fetching Problem

查看:76
本文介绍了SQL存储过程获取问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,亲爱的朋友,我创建了一个存储过程,当我使用=运算符而不是like关键字时,它运行良好.如果我在Sql Server中使用like关键字,则它正在运行,但在asp.net + C#页面中却无法正常工作,但是如果我在过程中使用=运算符,它将在Asp.net页面上很好地工作,而我没有遇到任何问题.

 选择 J.JobID  From  dbo.Jobs J 位置 J.关键字 @关键字 + %'  @ Exp   AND  J.Location =  @Location   AND  J.FunctionalArea =  @ FunctionalArea 
      AND  J.Industry =  @ Industry   AND  J.PostedDate  BETWEEN (GETDATE()- @ Freshness ) AND (GETDATE())
     订单  BY  J.PostedDate  DESC  


请告诉我是否有任何问题,当我使用=运算符而不是Like关键字,但一切正常时,但我需要Like关键字,请帮助我.

解决方案

添加
到存储过程,并查看将@Keyword传递给SQL的内容.您可能只是在语句中加了引号.


此代码没问题,此代码没有问题,但传递的参数有问题.


问题是在这段代码中,我几乎没有提到Like @Keyword +``%''之间的空格,它应该采用这种格式@Keyword +''%''.现在正在工作.我不知道那里是什么,但是在解决之后,我解决了这个问题.


Hello Dear Friends I have created a stored procedure that is working well when i use = operator instead of like keyword. If i use like keyword in Sql server it isworking but in asp.net +C# pages it is not working but if i use = operator in my procedure it will works good with Asp.net page i am not getting problem.

Select J.JobID From dbo.Jobs J Where J.Keywords Like @Keyword + '%' AND
     J.MinExp >= @Exp AND J.Location = @Location AND J.FunctionalArea = @FunctionalArea
     AND J.Industry = @Industry AND J.PostedDate BETWEEN (GETDATE() - @Freshness) AND (GETDATE())
     ORDER BY J.PostedDate DESC


Please tell me if there is any problem everything is working well when i use = operator instead of Like keyword but i need Like keyword please help me.

解决方案

Add

Print @Keyword


to your stored procedure and see what you pass as @Keyword to SQL. You may just have quote issue in your statement.


This code is ok there is no problem in this code, but problem in passed parameters.


problem is in this code just little that i had mention space between Like @Keyword + ''%'' it should be in this format @Keyword+''%''. Now it is working. I don''t know what was there but after doing this I solved this.


这篇关于SQL存储过程获取问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆