Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809

    Unanswered: sp_executesql with datetime parm

    does anyone have a working example of calling sp_executesql passing a datetime parameter? I can't get this to work. I even tried passing the datetime as a string but keep getting an error on converting a varchar to a datetime. I am calling with varchar, int and datetime parms, if I take out the datetime parm everything works.

    Any suggestion?
    Paul Young
    (Knowledge is power! Get some!)

  2. #2
    Join Date
    Mar 2004
    Posts
    45
    use northwind
    go

    declare @sql nvarchar(50), @dt datetime
    set @dt = '19980101'
    set @sql = N'SELECT OrderID FROM Orders WHERE OrderDate > @date'
    EXEC sp_executesql @sql, N'@date datetime',@dt
    Hans.

  3. #3
    Join Date
    Feb 2002
    Location
    Houston, TX
    Posts
    809
    Thanks!
    Paul Young
    (Knowledge is power! Get some!)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •