I have SP like :
CREATE PROCEDURE MySP
(
@startdate datetime = null,
@enddate date开发者_如何转开发time = 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
I want to view select @startdate
value, How can i do this?
You execute the stored procedure.
exec MySP
Result:
(No column name)
2011-08-10 00:00:00.000
Edit
Stored procedure with output parameter @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
Use like this
declare @D datetime
exec MySP @D out
select @D
精彩评论