Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenting fields

Status
Not open for further replies.

Phil99

Programmer
Jul 12, 2002
32
0
0
GB
Hi,

I want to concatenate a list of variables which are then written to another field and display them in neat columns.

I've used the tab character below but if one field is too long it shifts all other fields to the right.

set @Ticket_Details = @Ticket_Details + @Ticket_No + char
(9) + @Status + char(9) + @Logged_Date

Is there a way to ensure the fields will always be lined up.

Thanks

Phil
 
You want to line it up.Why not using char(13)

set @Ticket_Details = @Ticket_Details + @Ticket_No + char
(13) + @Status + char(13) + @Logged_Date
 
Hi,

Try this code


Declare @Ticket_Details as varchar(500)
--declare @Ticket_Details as varchar(10)
declare @Ticket_No as varchar(10)
declare @Status as varchar(10)
declare @Logged_Date as varchar(10)

SET @Ticket_Details = ''
SET @Ticket_No = '123000000'
SET @Status = '45640000000'
SET @Logged_Date = '01/01/01'

set @Ticket_Details = @Ticket_Details + @Ticket_No +space(10-len(@Ticket_No))+ char
(9) + @Status + +space(10-len(@Status))+ + char(9) + @Logged_Date

print @Ticket_Details

U can also use replicate function to do the same functionality...
hope this is wht u r looking for..

Sunil
 
Thanks everyone for your help. I used Sunil's suggestion which works really well.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top