Prefix all columns in T-SQL statement

后端 未结 3 1552

Given a table \"ABC\" with columns Col1, Col2 and Col3 it is possible to automatically generate something like the following:

SELECT
Col1 AS \'ABC_Col1\', 
C         


        
3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-12 04:05

    You seem confused as to what column aliases do. As you can see in your select clause, you're already only selecting fields from T0 by referencing T0.*. You can still reference those fields as T0. later in your query without aliasing the fields, you will just have to refer to them by their full field name, ie, T0.[My Users Suck And Make Really Long Field Names].

    EDIT: To be more clear, you can not change the prefix of a field by aliasing it. You can only change the name of it. The prefix of the field is the alias of the table that it comes from.

提交回复
热议问题