我喜欢SP:
CREATE PROCEDURE MySP
(
@startdate datetime = null,
@enddate datetime = null
)
AS
BEGIN
declare @date datetime
Set @date= convert(datetime,convert(varchar(10),getdate(),101))
SET @startdate = ISNULL(@startdate,convert (datetime,convert(varchar(10),getdate(),101)))
select @startdate -- i want to select and view this value
END
GO
我想查看select @startdate
值,我该怎么做?
答案 0 :(得分:3)
执行存储过程。
exec MySP
结果:
(No column name)
2011-08-10 00:00:00.000
修改强>
带输出参数@startdate
的存储过程alter PROCEDURE MySP
(
@startdate datetime = null out,
@enddate datetime = null
)
AS
BEGIN
declare @date datetime
Set @date= convert(datetime,convert(varchar(10),getdate(),101))
SET @startdate = ISNULL(@startdate,convert (datetime,convert(varchar(10),getdate(),101)))
END
像这样使用
declare @D datetime
exec MySP @D out
select @D