DBA > Job Interview Questions > Sybase Interview Questions and Answers

Is it possible to concatenate all the values fro

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

Is it possible to concatenate all the values from a column and return a single row?

It was possible to concatenate a series of strings to return a single column, in a sort of analogous manner to sum summing all of the numbers in a column. However, this was not a 'feature' but a bug, so if you are running an EBF that has the fix for CR 210688, this is no longer possible

Use a case statement, a la,

1. declare @string_var varchar(255)
2.
3. select @string_var = ""
4.
5. select @string_var = @string_var +
6. (case 1 when 1
7. then char_col
8. end)
9. from tbl_a
10.
11. print "%1!", @string_var
12. go
(1 row affected)
ABCDEFGH
(8 rows affected)
1. select * from tbl_a
2. go
char_col
--------
A
B
C
D
E
F
G
H

(8 rows affected)
1.

(Continued on next question...)

Other Job Interview Questions