• Jan Van der Eecken - Wednesday, December 20, 2017 1:12 PM

    sgmunson - Wednesday, December 20, 2017 12:49 PM

    Well, there's always INFORMATION_SCHEMA.COLUMNS to play with.   If you go the dynamic SQL route, you can find all the column names for any given table, and then use the QUOTENAME function to enclose them in brackets so you don't have column name issues.

    I'm aware of that, Steve, but that's exactly what I'm trying to avoid.

    Yeah, I understand, ... but ...  what's the alternative?   If you have specific columns that you know the starting x number of characters for the column name, dynamic SQL is probably the ONLY way to have automation handle things.   Also, you might be able to use a Script Task within SSIS and use ADO code with VB or C# to maybe make the code more specific than doing it all in T-SQL, but no matter how you slice it, something will have to be dynamic.

    I've seen Lynn's post about using the sys.tables or sys.views or sys.columns type of metadata info instead of INFORMATION_SCHEMA, and for some things, those are more practical, but if you just need to identify column names for some dynamic SQL ...

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