Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. GetDate() in Stored Procedure

GetDate() in Stored Procedure

Scheduled Pinned Locked Moved Database
databasecsharpbeta-testingquestionannouncement
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Michael Flanakin
    wrote on last edited by
    #1

    I have a stored procedure that updates data in one table and saves who updated it and the update date in another table. For some reason, the user ID is updating, but the date isn't. I'm using the GetDate() function, so it should work fine, as far as I know. It's like the update statement doesn't even recognize the second column. Before you ask, I know the SQL is correct. In fact, if I execute the stored procedure from QA, everything works fine. Are there any issues with using the GetDate() function in a stored procedure? I wouldn't think there are. Here's my SQL:

    UPDATE UserDefinedRows
    SET UpdatedByUserId = @UserID,
    UpdateDate = GETDATE()
    WHERE UserDefinedRowID = @UserDefinedRowID

    Michael Flanakin Web Log

    M Q 2 Replies Last reply
    0
    • M Michael Flanakin

      I have a stored procedure that updates data in one table and saves who updated it and the update date in another table. For some reason, the user ID is updating, but the date isn't. I'm using the GetDate() function, so it should work fine, as far as I know. It's like the update statement doesn't even recognize the second column. Before you ask, I know the SQL is correct. In fact, if I execute the stored procedure from QA, everything works fine. Are there any issues with using the GetDate() function in a stored procedure? I wouldn't think there are. Here's my SQL:

      UPDATE UserDefinedRows
      SET UpdatedByUserId = @UserID,
      UpdateDate = GETDATE()
      WHERE UserDefinedRowID = @UserDefinedRowID

      Michael Flanakin Web Log

      M Offline
      M Offline
      Michael Flanakin
      wrote on last edited by
      #2

      Oh, and when the SP gets run from the application, it gets run by a DBO user. Michael Flanakin Web Log

      M 1 Reply Last reply
      0
      • M Michael Flanakin

        Oh, and when the SP gets run from the application, it gets run by a DBO user. Michael Flanakin Web Log

        M Offline
        M Offline
        Michael Flanakin
        wrote on last edited by
        #3

        I just logged into QA as the user the application is running as and the SP executed fine. I'm still having problems when executing it from the app, tho. This is pretty ridiculous. Michael Flanakin Web Log

        1 Reply Last reply
        0
        • M Michael Flanakin

          I have a stored procedure that updates data in one table and saves who updated it and the update date in another table. For some reason, the user ID is updating, but the date isn't. I'm using the GetDate() function, so it should work fine, as far as I know. It's like the update statement doesn't even recognize the second column. Before you ask, I know the SQL is correct. In fact, if I execute the stored procedure from QA, everything works fine. Are there any issues with using the GetDate() function in a stored procedure? I wouldn't think there are. Here's my SQL:

          UPDATE UserDefinedRows
          SET UpdatedByUserId = @UserID,
          UpdateDate = GETDATE()
          WHERE UserDefinedRowID = @UserDefinedRowID

          Michael Flanakin Web Log

          Q Offline
          Q Offline
          Qaiser Mehmood Mughal
          wrote on last edited by
          #4

          UpdateDate = GETDATE() please past the error message hint, if UpdateDate is datatime then it will work properly. Qaisar Mehmood Mughal ............................................................................... May Allah gave u success in all fields of life. (Aameen) ............................................................................... Software Engineer ISF - Islamabad Software Factory 3rd Floor, Software Technology Park Constitution Avenue, Islamabad 44000, Pakistan www.isf.com.pk qaisar@isf.com.pk , qmmughal@gmail.com Phone: +92 (51) 2825387 : 0321-5226623

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups