开发者

How do I select any value from SP?

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜