存储过程使用默认值
USE [Test_Blog]
GO
/****** Object: StoredProcedure [dbo].[db_blog_tags_gettags] Script Date: 06/16/2010 13:58:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[db_blog_tags_gettags]
(
@field nvarchar(500)='*',
@where nvarchar(500)
)
AS
BEGIN
declare @sql nvarchar(3000)
if @where<>''
set @sql =' select top 1 '+@field+' from tags where '+@where+''
else
set @sql=' select top 1 '+@field+' from tags'
exec(@sql)
END
exec db_blog_tags_gettags @where= 'id>3'
posted on 2010-06-16 14:13 jianshaohui 阅读(350) 评论(0) 编辑 收藏 举报