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. What's the syntax error?

What's the syntax error?

Scheduled Pinned Locked Moved Database
sql-serverdatabasehelpquestion
6 Posts 4 Posters 6 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.
  • Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #1

    What's the syntax error in the following TSQL stored procedure call?

    EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;

    SSMS is telling me "Syntax error near keyword CONVERT"

    The difficult we do right away... ...the impossible takes slightly longer.

    R J R 3 Replies Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      What's the syntax error in the following TSQL stored procedure call?

      EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;

      SSMS is telling me "Syntax error near keyword CONVERT"

      The difficult we do right away... ...the impossible takes slightly longer.

      R Offline
      R Offline
      Ron Nicholson
      wrote on last edited by
      #2

      I typed it in as a Select and it worked fine. Changing it to and EXEC proc failed. Try converting the date then see.

      DECLARE @DateT DateTime = Convert(DateTime, '09-09-2024 14:14:28')
      EXEC StoredProcName 9,'12341239487','1', @DateT,'calculated','','','',0,0,0,0,0,0,0,0,0;

      This works fine for me. Raiserror is the same way, can't cast or convert inline.

      Jack of all trades, master of none, though often times better than master of one.

      Richard Andrew x64R 1 Reply Last reply
      0
      • R Ron Nicholson

        I typed it in as a Select and it worked fine. Changing it to and EXEC proc failed. Try converting the date then see.

        DECLARE @DateT DateTime = Convert(DateTime, '09-09-2024 14:14:28')
        EXEC StoredProcName 9,'12341239487','1', @DateT,'calculated','','','',0,0,0,0,0,0,0,0,0;

        This works fine for me. Raiserror is the same way, can't cast or convert inline.

        Jack of all trades, master of none, though often times better than master of one.

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #3

        Thanks, Ron. I guess it's not a huge problem, but it is annoying!

        The difficult we do right away... ...the impossible takes slightly longer.

        1 Reply Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          What's the syntax error in the following TSQL stored procedure call?

          EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;

          SSMS is telling me "Syntax error near keyword CONVERT"

          The difficult we do right away... ...the impossible takes slightly longer.

          J Offline
          J Offline
          jschell
          wrote on last edited by
          #4

          Interesting. Not a new problem apparently https://stackoverflow.com/questions/5967035/using-function-as-a-parameter-when-executing-a-stored-procedure[^]

          1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            What's the syntax error in the following TSQL stored procedure call?

            EXEC StoredProcedureName 9,'723147504','1',CONVERT(DATETIME, '09-27-2024 14:14:28'),'calculated','','','',0,0,0,0,0,0,0,0;

            SSMS is telling me "Syntax error near keyword CONVERT"

            The difficult we do right away... ...the impossible takes slightly longer.

            R Offline
            R Offline
            Richard Deeming
            wrote on last edited by
            #5

            If the parameter is typed as datetime, you shouldn't need to explicitly convert the string literal when you pass it in. However, it would probably be best to use the unambiguous date format (yyyyMMdd):

            EXEC StoredProcedureName 9, '723147504', '1', '20240927 14:14:28', 'calculated', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0;


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            Richard Andrew x64R 1 Reply Last reply
            0
            • R Richard Deeming

              If the parameter is typed as datetime, you shouldn't need to explicitly convert the string literal when you pass it in. However, it would probably be best to use the unambiguous date format (yyyyMMdd):

              EXEC StoredProcedureName 9, '723147504', '1', '20240927 14:14:28', 'calculated', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0;


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #6

              I'll give this a try when I'm back in my office.

              The difficult we do right away... ...the impossible takes slightly longer.

              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