on 2012 Jul 09 10:56 AM
Just a slight issue:
Something I frequently need: a comma-separated list of all column names ordered by column id (i.e. position) for one particular table, and I'm usually needing it while writing (ad-hoc) SQL code - so I'm not asking for a Sybase Central wizard approach:)
I'm using this frequently to build "SELECT col1 ... coln FROM MyTable ... " statements or the like.
Is there any builtin function - or anything better than the catalog query I'm about to post?
Request clarification before answering.
What I'm typically using is something like the following:
select list (column_name, ', ' order by column_id) from systabcol key join systab where table_name = 'MyTableName';
Works fine for v10 and above (and I'm posting it here to remind me of that tiny template), but I guess there are better builtin ways...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I've used this approach before:
You'll get two rows. Top row is column names. Bottom row is data. Delete data and you have a comma separated list of column names.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
29 | |
9 | |
8 | |
7 | |
7 | |
7 | |
6 | |
6 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.