Using getdate as a parameter in Stored Procedures

  • I have delared a parameter in a stored procedure as @rundate with a datatype of datetime.

    When I went to execute the stored procedure in the usual way

    "EXEC SP_NAME @rundate = getdate"

    SQL Serever returns an error message that there is an error converting nvarchar to datetime.

    Does anyone know whether SQL Server stores getdate as nvarchar and if so is there a work around ?

  • Hrm. That's a peculiar bug. I can recreate it. A workaround would be:

    
    
    DECLARE @ADate datetime
    SET @ADate = GETDATE()
    
    
    EXEC SP_NAME @rundate = @ADate

    K. Brian Kelley

    bkelley@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/bkelley/

    K. Brian Kelley
    @kbriankelley

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

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