Does anyone know where to find or how to write a quick user defined fucntion
that will return a table object when passed the string name of the table
object. The reason why I want dynamicallly set the table name in a stored
procudue WITHOUT using concatination and exec a SQL String.
Hence
If @small_int_parameter_previous = 1 then
@vchar_tablename = "sales_previous"
else
@vchar_tablename = "sales"
End
select * from udf_TableLookup(@vchar_tablename )
So if I pass 1, that means I want all records from "sales_previous"
otherwise give me all records from "sales" (Sales_Previous would last years
sales data for example).
udf_TableLookup would I guess lookup in sysobjects for the table name and
return the table object? I don't know how to do this.
I want to do this to avoid having 2 stored procedures..one for current and
one for previous year.
Please respond to group so others may benfiit from you knowledge.
Thanks
Erik