Regarding string concatenation in stored procedures

  • hi,

    can any one suggest me for string concatenation inside stored procedures..

    alter proc sp_test as

    declare @temp1 varchar, @temp2 varchar, @temp3 varchar

    set @temp1='MS'

    set @temp2='SQL'

    set @temp3 = @temp1 + @temp2

    print @temp3

     

    whn i exec this-- sp_test

    output is--only M

    thanx in advance,

    ramesh.

  • Try giving the Variables sizes:

    declare @temp1 varchar(10), @temp2 varchar(10), @temp3 varchar(10)


    wayne

  • thanx wayneph 

    it is working

  • One note: building on Wayne's example, you probably want to make @temp3 varchar(20) - the sum of the length of @temp1 and @temp2.

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

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