• Sean Lange (7/2/2013)


    ulisseslourenco (7/2/2013)


    Thanks for respond me.

    I have a question: Is allowed use exec statement into a function? I ask that because I have to return a select into a application calling one

    SELECT * FROM DBO.UF_DADOS ('CARRO_01')

    No in SQL a function cannot use any dynamic sql.

    I have to ask, why have you created such a generic piece of code? This is like "one function to rule them all". You would never consider doing this in a programming language yet we see it so frequently in the database world. The performance of things like this degrade as more and more data enters the system and there is nothing you can do to make it faster because everything is so generic.

    The other functions work as well, the problem occurs because the programmer can insert a several of information into that tables and union statement into function could replace header table lines in a column name in function return. As I wrote in initial post I thought use sp_rename, however I afraid decreasing performance.

    In relation, use other language, I don't know if it's possible, because this process will work into an application that runs sql only.

    best regards