当前位置: 代码迷 >> Sql Server >> 简单查询有关问题
  详细解决方案

简单查询有关问题

热度:86   发布时间:2016-04-27 17:37:58.0
简单查询问题
CREATE       procedure   search_info
@tab   varchar(50),                                           --需查询的表格
@typ   varchar(50),                                           --查询的类型
@inf   varchar(50),                                           --根据查询内容范围(title,content,title&content)
@content   varchar(1000)                                 --查询的内容
as
                declare   @sql   varchar(300)
                set   nocount   on
set   @sql= "select   title,uptime,content   from   "[email protected]+ "   where   type= "[email protected]+ "   and   "[email protected]+ "   like   '% "[email protected]+ "% '   order   by   id   desc "
exec(@sql)
--------------------------
为什么会创建不成功,如何规范传入参数的调用,我在这里先谢谢各位了.

------解决方案--------------------
这样写:
CREATE procedure search_info
@tab varchar(50), --需查询的表格
@typ varchar(50), --查询的类型
@inf varchar(50), --根据查询内容范围(title,content,title&content)
@content varchar(1000) --查询的内容
as
declare @sql varchar(300)
set nocount on
set @sql= 'select title,uptime,content from '[email protected]+ ' where type= '[email protected]+ ' and '[email protected]+ ' like ' '% '[email protected]+ '% ' ' order by id desc '
exec(@sql)
------解决方案--------------------
CREATE procedure search_info
(
@tab varchar(50), --需查询的表格
@typ varchar(50), --查询的类型
@inf varchar(50), --根据查询内容范围(title,content,title&content)
@content varchar(1000) --查询的内容
)
as
set nocount on
declare @sql varchar(300)

set @sql= "select title,uptime,content from "[email protected]+ " where type= "[email protected]+ " and "[email protected]+ " like '% "[email protected]+ "% ' order by id desc "
exec(@sql)
  相关解决方案