How to pass today's date to a store procedure?

  • I have a store procedure as below:

    create PROCEDURE dbo.sp_test

    @mydate VARCHAR(20)

    as

    begin

    print @mydate

    end

    If I run

    exec sp_test '03/21/2011'

    it works.

    How to pass today's date to it? The following code do not work.

    exec sp_test getdate()

  • DECLARE @today DATETIME

    SET @today = GETDATE()

    EXEC proc @MyDate = @today

    Can't send in a function as a value to a parameter.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply