日期:2014-05-17 浏览次数:20544 次
CREATE PROCEDURE [dbo].[proc_get_pic_By_key]
@topnum int,
@wherestr NVARCHAR(250)
AS
BEGIN
select top @topnum photo_name,minipic from photo where minipic<>'' @wherestr order by picid desc
END
CREATE PROCEDURE [dbo].[proc_get_pic_By_key]
@topnum int,
@wherestr NVARCHAR(250)
AS
BEGIN
exec('select top '+@topnum +' photo_name,minipic from a where minipic<>'''''+@wherestr +' order by picid desc')
END
ALTER PROCEDURE [dbo].[proc_get_pic_By_key]
@topnum int,
@wherestr NVARCHAR(250)
AS
BEGIN
DECLARE @sql NVARCHAR(max)
SET @sql = N'
select top (@topnum) photo_name,minipic from photo where minipic<>'''' '+ @wherestr +' order by picid desc
'
PRINT @sql
EXEC sp_executesql @sql, N'@topnum int', @topnum
END
GO
EXEC [proc_get_pic_By_key] 1, 'AND minipic = ''TEST'''