Fully Qualified Resultset

  • In theory I've joined 4 tables.

    I've run a Select * (yeah I know)..

    Is there an option to show tableName(or aliasName).columnName in the resultset?

    Regards,

    Erin

  • Erin Ramsay (7/11/2014)


    In theory I've joined 4 tables.

    I've run a Select * (yeah I know)..

    Is there an option to show tableName(or aliasName).columnName in the resultset?

    Regards,

    Erin

    Nope. The only way to get a different name for the fields in the resultset is to specify one as an alias. You might be able to do something with INFORMATION_SCHEMA.COLUMNS that would end up as dynamic SQL, but would you want to add that level of complexity?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • Not directly, but you could easily generate that code using sys.columns. I strongly suggest avoiding the INFORMATION_SCHEMA views, as they are less complete as well extremely slow and tending to cause deadlocks, even though when you look at the corresponding view definition it doesn't look as if they should.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • I stay away from the INFORMATION_SCHEMA views as well. As mentioned, they are incomplete when it comes quite a bit of information. Also, they are not as portable as some would make you think. I think I have seen them in MySQL, but I haven't seen them in Oracle and I haven't looked in PostgreSQL so can't say yes or no there.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply