Calling a stored procedure with datetime parameters

  • How do you pass a datetime parameter to a stored procedure.

    Enclosing the date in single quotes fails and my clever attempt to use a variable is no more successful:

    use databasename

    declare @wdate as datetime

    set @wdate = convert(datetime, '20070914 00:00:00:000')

    exec dbo.sp_Get_CDRL37_Data(@wdate, @wdate)

    /* Line 5: Incorrect syntax near '@wdate'. */

    Any ideas, anyone?

  • try taking out the parenthesis.

    exec dbo.sp_Get_CDRL37_Data @wdate, @wdate

  • I think it might not like the () brackets.

    EXECUTE master..xp_cmdshell ('dir *.exe')

    EXECUTE master..xp_cmdshell 'dir *.exe'

  • Thanks, Rich and Allen... I guess I'm too much of a VB programmer, treating SPs as functions!

Viewing 4 posts - 1 through 3 (of 3 total)

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