Assign string in select

Last Post 10 Aug 2010 09:41 AM by rm. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
werice
New Member
New Member

--
10 Aug 2010 09:10 AM
I have a table that has the following fields and values:
Slots:55 Days:20 and Target:1100

I want to return a select that looks like below:

(SLOTS:55) x (DAYS:20) = (Target: 1100)

Does anyone know how to capture data in a string and have the select look like above?

Thanks!!!
Bill
russellb
New Member
New Member

--
10 Aug 2010 09:40 AM
SELECT '(Slots:' + convert(varchar(5), Slots) + ') X (DAYS:' + Convert(varchar(6), Days) + ') = (Target: ' + Convert(varchar(6), Target) + ')'
FROM yourTable
rm
New Member
New Member

--
10 Aug 2010 09:41 AM
If values have same format, can try with following:

select '(' + col1 + ') x (' + col2 + ') = (' + col3 + ')' from table where ...
You are not authorized to post a reply.

Acceptable Use Policy