我有以下查詢哪些工作正常,但我也想使用like關鍵字獲得記錄。我的查詢如下,我想使用像關鍵字
USE [POBox]
GO
/****** Object: StoredProcedure [dbo].[test] Script Date: 07/06/2009 12:55:39 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[test] --'DateTime','1','10'
(
@p_SortExpression NVARCHAR(100),
@p_StartIndex INT,
@p_MaxRows INT
)
AS
SET NOCOUNT ON;
IF LEN(@p_SortExpression)= 0
SET @p_SortExpression = 'DateTime DESC'
DECLARE @Sql NVARCHAR(4000)
SET @Sql ='SELECT ID, DateTime, Subject, CreatedBy, ToReceipientID , ReceiverStatus
FROM
(
SELECT ID, DateTime, Subject,CreatedBy, ToReceipientID, ReceiverStatus,
ROW_NUMBER() OVER(ORDER BY ' + @p_SortExpression + ') AS Indexing
FROM ComposeMail
WHERE (Subject Like '%+ test +%')
)
AS NewDataTable
WHERE Indexing > '+ CONVERT(NVARCHAR(10), @p_StartIndex) + ' AND Indexing<=(' + CONVERT (NVARCHAR(10),@p_StartIndex)+'+'+ CONVERT(NVARCHAR(10),@p_MaxRows)+')'
EXEC sp_executesql @sql
任何人都可以幫忙嗎?我如何使用像,我也想用它作爲參數。
感謝你的朋友我得到它與你顯示給我的語法 – 2009-07-06 10:20:29