Error in SP with PRINT statement

  • Hi,

    I added another local variable to a stored proc and got the following error:

    'Only constants, expressions, or variables allowed here. Column names are not permitted.'

    This error referred to the following PRINT statement:

    
    
    PRINT "There are no records dated after the " + CONVERT(VARCHAR(20),@date) + " for paper ID: " + CONVERT(VARCHAR(6),@paper_id)

    This statement was working fine until adding the new variable, removing the PRINT statement resolves the error. Can anyone tell me why this has occured and how do I get my PRINT statement to work again?

    TIA

  • The double quotes are being interpreted as object identifiers ie referring to tables. If you want to use double quotes, you can insert the statement set quoted_identifier off at teh top of the procedure.

    Alternatively, you could use single quotes.

    Paul Ibison

    Paul.Ibison@btinternet.com


    Paul Ibison
    Paul.Ibison@replicationanswers.com

  • Well, it seems that all of a sudden, it decided not to like " chars, changed them them to ' chars and all is well.

    
    
    PRINT 'There are no records dated after the ' + CONVERT(VARCHAR(20),@date) + ' for paper ID: ' + CONVERT(VARCHAR(6),@paper_id)

    Oh well, such is life!

  • I have run into this problem with double qoutes and for that reason I avoid them whenever possible.

    Robert Marda

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems

  • Ditto. I avoid double quotes as well. Stick with singles.

    Steve Jones

    steve@dkranch.net

Viewing 5 posts - 1 through 4 (of 4 total)

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