Results 1 to 4 of 4
  1. #1
    Join Date
    May 2003
    Posts
    40

    Unanswered: string concatenation

    create procedure CheckSQLErrors( @TheCode integer, @TheState integer, @Routine varchar(40), @Help varchar(40))
    as
    begin
    { call LogMsg('SQLA',@Routine,@Help,'sqlstate=' + @TheState +
    ', sqlcode=' + @TheCode) }
    end


    I m getting this error.
    "Incorrect syntax near + "


    + is used for string concatenation. I tried to use CAST to convert
    @TheState and @TheCode variables to varchar but did not work. Can you help me out?



    FYI
    LogMsg is a sproc

    create procedure
    dbo.LogMsg( @aAppName varchar(18), @aRoutine varchar(20), @aType varchar(5), @aMsg varchar(255))
    as
    begin
    insert into MessageLog(strAppName,strRoutineName,strType,strMe ssage) values(
    @aAppName,@aRoutine,@aType,@aMsg)
    end
    GO




    Thks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    What's CALL? or { }?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    May 2003
    Posts
    40
    Brett

    It is just exec . Can you tell me the soln for the concatenation.



    Tks

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Is this what you want?

    Code:
    SELECT @TheState = 'sqlstate='+ TheState, @TheCode = ', sqlcode=' + @TheCode
    
    EXEC LogMsg 'SQLA', @Routine, @Help, @TheState, @TheCode
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •