Search code examples
kdbq-lang

Store a column as a string in kdb


I have a table with numerous columns. I'm trying to take the data from one of the columns and return it as a string.

For instance, if I had:

A B C
1 2 3
4 5 6
7 8 9

I would like to take column B and store 258 as a string. How would I do this?


Solution

  • Like this?

    q)raze exec string B from ([] A:1 4 7;B:2 5 8;C:3 6 9)
    "258"
    

    Or are you trying to change the type of the column in the table?

    q)update string B from ([] A:1 4 7;B:2 5 8;C:3 6 9)
    A B    C
    --------
    1 ,"2" 3
    4 ,"5" 6
    7 ,"8" 9