I need to get a value from a dynamic data base, and I thought that the best way to do this was by using a scalar function.
I'm not too experianced in writting Functions... so I thought I'd post here and see if it is possible, and if so, how
Basically, I will be using 3 parameter:
- varchar @DataSource (the datasource string in the form of "server=SRV;uid=USER;pwd=PWD;database=DB;")
- int @RecordId (the primary key id column of the table)
- varchar @TableName (the name of the table)
All tables have this common structure:
- INT [id]
- VARCHAR [title]
I want to return the Varchar @Title based on my provided parameters.
How would I go about doing this

How to write a Function that can return a value from a dynamic database?
HDVD
Tikkam J
Chris Keeble
I see...
I'm not really sure what a linked server is, and whether it would be the best solution.
What I am basically trying to achieve is:
Reporting service pull records from db_a, which have reference to db_x (in the form of datasource, record_id, table_name)... and I want to get the title of the reference into my report.
I'm now writing this in code, so that a new bit of sql execution needs to take place, but I'm sure this is very inefficient.