set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id='+RTRIM(@cid)+' AND Published=1'
解决方案 »
- 有人能讲一下left join,right join,inner join等连接的具体用法吗?
- 类型转换的错误
- 求一个简单SQl语句,高手指点阿~~~
- 有几个sql语句不会写,请高手帮忙,谢谢!
- 新手的问题,关于设置检查约束的
- SQL2000提示:[sql-dmo]必须使用sql server 2005管理工具才能连接此服务器??
- 有关表中数据循环替代的问题
- 救人啊!,update後的數據如何恢復
- 哪儿能下载sql server 2000
- 时间怎么运算?KingSunSha(弱水三千) xzou(缺齿小狼)进来吧
- 我对产品定义了好多属性和值,我怎么才能找出符合某些属性值的某些产品,一条一条去查效率太低!!!
- 当ntext某个字段数据大于8000时候,updatetext无法全部匹配替换的问题。
USE [hotcewebsite]
GO
/****** 对象: StoredProcedure [dbo].[articleList_proc] 脚本日期: 01/08/2009 09:24:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- ===========================================
ALTER PROCEDURE [dbo].[articleList_proc]
/*
后台ARTICLELIST文件所用的存储过程
*/
@cid int, ---文章分类号
@sj varchar(20),---标题
@keyword varchar(50), ---关键字
@AddUser_id int, ---写入者号
@IsPass int, ---是否通过
@startTime varchar(50),---开始时间
@endTime varchar(50)---结束时间
AS
declare @firstStr varchar(200)
set @firstStr = 'select top 100 * from Article '
declare @condition varchar(1000)
set @condition = ' WHERE DeleteFlag=0 AND ArticleClass_id=@cid AND Published=1'
if (@sj <> null)
begin
set @condition = @condition+' AND Subject LIKE @sj '
end if(@keyword <> null)
begin
set @condition = @condition+' AND [Keyword] LIKE @keyword '
end if @AddUser_id>0
begin
set @condition = @condition+' AND AddUser_id=@AddUser_id '
end if(@IsPass>=0)
begin
set @condition = @condition+' AND IsPass=@IsPass'
end if(@startTime <>null and @endTime <>null)
begin
set @condition = @condition+' AND (AddTime Between @startTime AND @endTime)'
end
declare @lastStr varchar(200)
set @lastStr = ' order by [id] desc'
set @condition = @firstStr+@condition+@lastStr
exec (@condition)
-- =============================================
-- Example to execute the stored procedure
-- =============================================
execute [dbo].[articleList_proc] '50081','诺基亚','诺基亚','50','1','2008-12-8 11:43:40','2008-12-10 17:49:00'
Go