Create a stored procedure

  • Comments posted to this topic are about the item Create a stored procedure

  • I get error

    Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

    because "Column" is a reserved keyword and needs to be delimited if you want to use it as a column (e.g. [Column]).

  • happycat59 (10/14/2014)


    I get error

    Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

    because "Column" is a reserved keyword and needs to be delimited if you want to use it as a column (e.g. [Column]).

    You are right,

    Given answer is wrong, although syntax is right, Still Sql server will give error on given procedure.

    Admin should review once again.

    Vimal LohaniSQL DBA | MCP (70-461,70-462)==============================The greatest barrier to success is the fear of failure ** Success is a journey not a destination**Think before you print, SAVE TREES, Protect Mother Nature

  • Yes happycat59 I got the Same Error......:hehe:

  • same error:crazy:

  • The answer is right for this kind of procedure :

    CREATE PROCEDURE my_sp AS

    SELECT id FROM my_table

    The answer is Wrong for below procedure

    CREATE PROCEDURE my_sp AS

    SELECT Column FROM my_table

    Vimal LohaniSQL DBA | MCP (70-461,70-462)==============================The greatest barrier to success is the fear of failure ** Success is a journey not a destination**Think before you print, SAVE TREES, Protect Mother Nature

  • Same error: Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

  • happycat59 (10/14/2014)


    I get error

    Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

    because "Column" is a reserved keyword and needs to be delimited if you want to use it as a column (e.g. [Column]).

    +1

    Please, before you submit a qotd, run a minimal test!

  • By the way, no error if you use this syntax:

    CREATE PROCEDURE my_sp AS

    SELECT [column] FROM my_table

  • That's what probably the author meant but it doesn't change the fact that the query as provided returns an error.

  • Mauricio N (10/15/2014)


    Same error: Msg 156, Level 15, State 1, Procedure my_sp, Line 2

    Incorrect syntax near the keyword 'FROM'.

    +1


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

  • Maybe the author chose the column name deliberately to catch out people who just run the SQL rather than thinking about their answer? I mean, the error about incorrect syntax near "FROM" isn't one of the available answer options, so it should be pretty obvious that's not what was intended.

  • paul.knibbs (10/15/2014)


    Maybe the author chose the column name deliberately to catch out people who just run the SQL rather than thinking about their answer? I mean, the error about incorrect syntax near "FROM" isn't one of the available answer options, so it should be pretty obvious that's not what was intended.

    Yes, it is, none of the above.

  • paul.knibbs (10/15/2014)


    I mean, the error about incorrect syntax near "FROM" isn't one of the available answer options, so it should be pretty obvious that's not what was intended.

    It would be covered by the "none of the above" option

  • paul.knibbs (10/15/2014)


    Maybe the author chose the column name deliberately to catch out people who just run the SQL rather than thinking about their answer? I mean, the error about incorrect syntax near "FROM" isn't one of the available answer options, so it should be pretty obvious that's not what was intended.

    That argument doesn't really hold water though. I'm sure some of the big (and not so big) hitters will be able to look at that code and see that it won't run without a second thought. The incorrect syntax error is implicitly one of the options because 'None of the Above' is a choice.

    I tend to look at the question and depending on what it's about, either answer it straightaway, pick an option that I think is right then run the code to confirm it or go off and research. In this case I actually chose the correct option initially but when I ran the code and got an error I changed my answer and got it wrong.


    On two occasions I have been asked, "Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?" ... I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
    —Charles Babbage, Passages from the Life of a Philosopher

    How to post a question to get the most help http://www.sqlservercentral.com/articles/Best+Practices/61537

Viewing 15 posts - 1 through 15 (of 64 total)

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