Maximum length of a Varchar Variable

  • Well there is no problem executing the query as is as I have posted and @query3 is not missing any apostophies as such as I closed it after = ' and + CONVERT(VARCHAR(100),@pkeycustomer) is the variable so when I execute it runs perfectly well and also it doesnot really matter whether @query3 is written as @Query3 from the execution point of view however it is a not good coding practise and I agree with you.

    Prasad Bhogadi
    www.inforaise.com

  • So, is there still aproblem or it is solved as you say you can execute the query?

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Actually I never had a problem executing this query but my very issue was that when I keep the total query in a single variable say @query1 and execute @query1 then the query is getting chopped off, every time I have a lengthy query I have to split it.  

    Prasad Bhogadi
    www.inforaise.com

  • That's what I meant. Splitting *should* not be necessary and what is the error message you're getting when you place all in one string?

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Well I found the problem with my code, basically I am calling the execute with a wrong syntax as

    exec @query1

    and then it is displaying an error

    Server: Msg 203, Level 16, State 2, Procedure MyProc, Line 38

    If it is called as

    exec (@query1) and it works fine.

     

    Thanks for all the quick responses and help.

     

    Prasad Bhogadi
    www.inforaise.com

  • How did I keep the nice format? I cheated!!!!!!!!!!!!!!!!!!

    I copied the code into Notepad, fixed the format and then copied that into the reply text box.

    -SQLBill

  • I do it too but it doesn't keep my indentation


    * Noel

  • Once again Notepad

    QA code formatting is lost when copying.

    Maybe we should opt for Word as editor

     

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 8 posts - 16 through 22 (of 22 total)

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