Getting information in database in structured format

  • I have 4 columns in sql server

    Name Class RollNo Section

    I want to get the concantenated value of these columns in one column in the address printable form as we are printing address on some envelope:

    Name

    Class

    RollNo

    Section

    Any body please help

  • You mean this?

    DEclare @name varchar(10),

    @Class varchar(10),

    @rNo int,

    @Section varchar(10),

    @Address varchar(50)

    SET @NAME = 'Gaurav'

    SET @Class = 'Tenth'

    SET @rNo = 100

    SET @Section = 'A'

    SET @Address = @name + char(13) + @Class + char(13) + convert(varchar(10),@rNo)

    + char(13) + @Section

    PRINT @Address

    ---------------------------------------------------------------------------------

  • do you mean for all rows? If so, you can do a SELECT and use the + operator to concatenate fields.

    SELECT name + CHAR(13) + class + CHAR(13) + rollno ...

    from MyTable

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

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