on 2022 Aug 22 4:44 AM
Hello, I have table with many columns and would like to do select like Select * from table and would like that result of query is alphabetically by column names Is this possible?
Regards
Tomaž
ALTER PROCEDURE "DBA"."SelectWithColumnsOrdered"(in @table_name char(100)) BEGIN declare @sql long varchar ; select list(cname, ', ' order by cname) into @sql from sys.syscolumns where tname = @table_name ; set @sql = 'select ' || @sql || ' from ' || @table_name ; execute immediate with result set on @sql ; END
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FWIW, with v17, indirect identifiers often help to omit execute immediate calls - however, I don't know whether they could also be of help for cases like this with a variable number of identifiers (here columns)... - just in case someone has an idea...
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.